[QuickContacts] copy sample to public repo

Xamarin.iOS 8.6.0.51
This commit is contained in:
Rustam Zaitov 2015-02-03 17:51:21 +03:00
Родитель b4a8a121bf
Коммит 3dd18edadf
44 изменённых файлов: 943 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<SampleMetadata>
<ID>b327a7de-a584-11e4-9c52-a8206629811d</ID>
<IsFullApplication>false</IsFullApplication>
<Level>Beginning</Level>
<Tags>iOS8, User Interface, Platform Features, Getting Started</Tags>
<SupportedPlatforms>iOS</SupportedPlatforms>
<Gallery>true</Gallery>
<MinimumLicenseRequirement>Starter</MinimumLicenseRequirement>
</SampleMetadata>

Просмотреть файл

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickContacts", "QuickContacts\QuickContacts.csproj", "{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
Ad-Hoc|iPhone = Ad-Hoc|iPhone
AppStore|iPhone = AppStore|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.AppStore|iPhone.Build.0 = AppStore|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Debug|iPhone.ActiveCfg = Debug|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Debug|iPhone.Build.0 = Debug|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Release|iPhone.ActiveCfg = Release|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Release|iPhone.Build.0 = Release|iPhone
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = QuickContacts\QuickContacts.csproj
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,13 @@
using System;
namespace QuickContacts
{
public enum ActionType
{
PickContact,
CreateNewContact,
DisplayContact,
EditUnknownContact
}
}

Просмотреть файл

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace QuickContacts
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
public override UIWindow Window { get; set; }
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>QuickContacts</string>
<key>CFBundleIdentifier</key>
<string>com.your-company.QuickContacts</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIMainStoryboardFile~ipad</key>
<string>Main</string>
<key>XSAppIconAssets</key>
<string>Resources/Images.xcassets/AppIcon.appiconset</string>
<key>XSLaunchImageAssets</key>
<string>Resources/Images.xcassets/LaunchImage.launchimage</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace QuickContacts
{
public class Application
{
// This is the main entry point of the application.
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
}
}

Просмотреть файл

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6724" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="auN-g9-0Zh">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6711"/>
</dependencies>
<scenes>
<!--QuickContacts-->
<scene sceneID="wex-5G-Fip">
<objects>
<tableViewController id="Lxj-0K-e12" customClass="QuickContactsViewController" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="4Xk-gL-inN">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" restorationIdentifier="Cell" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellID" id="FwI-ot-vJa">
<rect key="frame" x="0.0" y="119" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="FwI-ot-vJa" id="rlX-Qo-msy">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="Lxj-0K-e12" id="h1a-NN-0uS"/>
<outlet property="delegate" destination="Lxj-0K-e12" id="MaE-Bh-VBR"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="QuickContacts" id="TrG-jl-Ct7"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pTw-eF-BMK" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="489" y="187"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="gFx-UP-YNh">
<objects>
<navigationController definesPresentationContext="YES" id="auN-g9-0Zh" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="0xf-be-X4h">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="Lxj-0K-e12" kind="relationship" relationship="rootViewController" id="0DR-Nk-ZOp"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="swB-ta-pty" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="25" y="187"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

Просмотреть файл

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>title</key>
<string>Display Picker</string>
<key>description</key>
<string>Show a list of contacts.</string>
</dict>
<dict>
<key>title</key>
<string>Create New Contact</string>
<key>description</key>
<string>Add a new Person.</string>
</dict>
<dict>
<key>title</key>
<string>Display and Edit Contact</string>
<key>description</key>
<string>Show and edit a person record.</string>
</dict>
<dict>
<key>title</key>
<string>Edit Unknown Contact</string>
<key>description</key>
<string>Add data to an existing person or use them to create a new contact.</string>
</dict>
</array>
</plist>

Просмотреть файл

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{943B13AE-6CCA-4315-BE7C-8AB5B04FA50F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>QuickContacts</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>QuickContacts</AssemblyName>
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<DefineConstants>__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchDebug>true</MtouchDebug>
<CodesignKey>iPhone Developer</CodesignKey>
<IpaPackageName>
</IpaPackageName>
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<DefineConstants>__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
<DefineConstants>__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<BuildIpa>true</BuildIpa>
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\AppStore</OutputPath>
<DefineConstants>__MOBILE__;__IOS__;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignProvision>Automatic:AppStore</CodesignProvision>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Menu.plist" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="QuickContactsViewController.cs" />
<Compile Include="ActionType.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\Images.xcassets\" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-60%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-72.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-72%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-76.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-76%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Small-50.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Small-50%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Small.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Small%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Spotlight-40.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon-Spotlight-40%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon.png" />
<ImageAsset Include="Resources\Images.xcassets\AppIcon.appiconset\Icon%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Contents.json" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Landscape%402x~ipad.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Landscape~ipad.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait%402x~ipad.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait~ipad.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default%402x.png" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,275 @@
using System;
using UIKit;
using System.Collections.Generic;
using AddressBook;
using Foundation;
using CoreFoundation;
using AddressBookUI;
namespace QuickContacts
{
[Register("QuickContactsViewController")]
public class QuickContactsViewController : UITableViewController, IABPeoplePickerNavigationControllerDelegate
{
const int UIEditUnknownContactRowHeight = 81;
const string CellIdentifier = "Cell";
ABAddressBook addressBook;
NSMutableArray menuArray;
public QuickContactsViewController (IntPtr handle)
: base (handle)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "QuickContacts";
menuArray = new NSMutableArray (0);
NSError error;
addressBook = ABAddressBook.Create (out error);
CheckAddressBookAccess ();
}
void CheckAddressBookAccess ()
{
switch (ABAddressBook.GetAuthorizationStatus ()) {
case ABAuthorizationStatus.Authorized:
AccessGrantedForAddressBook ();
break;
case ABAuthorizationStatus.NotDetermined:
RequestAddressBookAccess ();
break;
case ABAuthorizationStatus.Denied:
case ABAuthorizationStatus.Restricted:
UIAlertController alert = UIAlertController.Create ("Privacy", "Permission was not granted for Contacts", UIAlertControllerStyle.Alert);
alert.AddAction (UIAlertAction.Create ("OK", UIAlertActionStyle.Default, null));
PresentViewController (alert, true, null);
break;
default:
break;
}
}
void RequestAddressBookAccess ()
{
addressBook.RequestAccess ((bool granted, NSError error) => {
if (!granted)
return;
DispatchQueue.MainQueue.DispatchAsync (() => AccessGrantedForAddressBook ());
});
}
void AccessGrantedForAddressBook ()
{
string plistPath = NSBundle.MainBundle.PathForResource ("Menu", "plist");
menuArray = NSMutableArray.FromFile (plistPath);
TableView.ReloadData ();
}
public override nint NumberOfSections (UITableView tableView)
{
return (nint)menuArray.Count;
}
public override nint RowsInSection (UITableView tableview, nint section)
{
return 1;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
NSDictionary item = menuArray.GetItem<NSDictionary> ((nuint)indexPath.Section);
var cell = tableView.DequeueReusableCell (CellIdentifier);
if (cell == null) {
if (indexPath.Section < 2) {
cell = new UITableViewCell (UITableViewCellStyle.Default, CellIdentifier);
cell.TextLabel.TextAlignment = UITextAlignment.Center;
} else {
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, CellIdentifier);
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
cell.DetailTextLabel.Lines = 0;
cell.DetailTextLabel.Text = (NSString)item ["description"];
}
}
cell.TextLabel.Text = (NSString)item ["title"];
return cell;
}
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
ActionType type = (ActionType)indexPath.Section;
switch (type) {
case ActionType.PickContact:
ShowPeoplePickerController ();
break;
case ActionType.CreateNewContact:
ShowNewPersonViewController ();
break;
case ActionType.DisplayContact:
ShowPersonViewController ();
break;
case ActionType.EditUnknownContact:
ShowUnknownPersonViewController ();
break;
default:
ShowPeoplePickerController ();
break;
}
}
public override nfloat GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
{
return indexPath.Section == (int)ActionType.EditUnknownContact ? UIEditUnknownContactRowHeight : tableView.RowHeight;
}
void ShowPeoplePickerController ()
{
var picker = new ABPeoplePickerNavigationController ();
// TODO: https://trello.com/c/ov8Rd2z1
picker.PerformAction2 += HandlePerformAction2;
picker.PredicateForEnablingPerson = NSPredicate.FromValue (true); // Enable selection for any person
picker.PredicateForSelectionOfPerson = NSPredicate.FromValue (false); // Don't select the person. Let me browse his properties
picker.PredicateForSelectionOfProperty = NSPredicate.FromValue (true); // Invoke call back when user tap on any property
// TODO: use flags instead https://trello.com/c/c4cwIMdE
picker.DisplayedProperties.Add (ABPersonProperty.Phone);
picker.DisplayedProperties.Add (ABPersonProperty.Email);
picker.DisplayedProperties.Add (ABPersonProperty.Birthday);
PresentViewController (picker, true, null);
}
void ShowPersonViewController ()
{
ABPerson[] people = addressBook.GetPeopleWithName ("Appleseed");
if (people != null && people.Length > 0) {
ABPerson person = people [0];
var pvc = new ABPersonViewController () {
DisplayedPerson = person,
AllowsEditing = true
};
pvc.PerformDefaultAction += HandlePerformDefaultAction;
NavigationController.PushViewController (pvc, true);
} else {
var alert = UIAlertController.Create ("Error", "Could not find Appleseed in the Contacts application", UIAlertControllerStyle.Alert);
alert.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Default, null));
PresentViewController (alert, true, null);
}
}
void ShowNewPersonViewController ()
{
var npvc = new ABNewPersonViewController ();
npvc.NewPersonComplete += HandleNewPersonComplete;
var navigation = new UINavigationController (npvc);
PresentViewController (navigation, true, null);
}
void ShowUnknownPersonViewController ()
{
using (var contact = new ABPerson ()) {
using (var email = new ABMutableStringMultiValue ()) {
bool didAdd = email.Add ("John-Appleseed@mac.com", ABLabel.Other);
if (didAdd) {
try {
contact.SetEmails (email);
var upvc = new ABUnknownPersonViewController {
DisplayedPerson = contact,
AllowsAddingToAddressBook = true,
AllowsActions = true,
AlternateName = "John Appleseed",
Title = "John Appleseed",
Message = "Company, Inc"
};
upvc.PersonCreated += HandlePersonCreated;
upvc.PerformDefaultAction += HandlePerformDefaultAction;
NavigationController.PushViewController (upvc, true);
} catch (Exception) {
var alert = UIAlertController.Create ("Error", "Could not create unknown user.", UIAlertControllerStyle.Alert);
alert.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Default, null));
PresentViewController (alert, true, null);
}
}
}
}
}
void HandlePerformAction2 (object sender, ABPeoplePickerPerformAction2EventArgs e)
{
string contactName = e.Person.FirstName;
string propValue = GetPropertyValue (e.Person, e.Property, e.Identifier);
string message = String.Format ("Picked {0} for {1}", propValue, contactName);
Console.WriteLine (message);
}
string GetPropertyValue(ABPerson person, ABPersonProperty property, int? identifier)
{
switch (property) {
case ABPersonProperty.Birthday:
return person.Birthday.ToString ();
case ABPersonProperty.Email:
return GetEmail (person, identifier.Value);
case ABPersonProperty.Phone:
return GetPhone (person, identifier.Value);
default:
throw new NotImplementedException ();
}
}
string GetEmail(ABPerson person, int identifier)
{
ABMultiValue<string> mails = person.GetEmails ();
return GetValue (mails, identifier);
}
string GetPhone(ABPerson person, int identifier)
{
ABMultiValue<string> phones = person.GetPhones ();
return GetValue (phones, identifier);
}
string GetValue(ABMultiValue<string> multiProperty, int identifier)
{
nint i = multiProperty.GetIndexForIdentifier (identifier);
string[] values = multiProperty.GetValues ();
return values [(int)i];
}
void HandlePerformDefaultAction (object sender, ABPersonViewPerformDefaultActionEventArgs e)
{
e.ShouldPerformDefaultAction = false;
}
void HandleNewPersonComplete (object sender, ABNewPersonCompleteEventArgs e)
{
DismissViewController (true, null);
}
void HandlePersonCreated (object sender, ABUnknownPersonCreatedEventArgs e)
{
NavigationController.PopViewController (true);
}
}
}

Просмотреть файл

@ -0,0 +1,104 @@
{
"images": [
{
"filename": "Icon-Small.png",
"size": "29x29",
"scale": "1x",
"idiom": "iphone"
},
{
"filename": "Icon-Small@2x.png",
"size": "29x29",
"scale": "2x",
"idiom": "iphone"
},
{
"filename": "Icon-Spotlight-40@2x.png",
"size": "40x40",
"scale": "2x",
"idiom": "iphone"
},
{
"filename": "Icon.png",
"size": "57x57",
"scale": "1x",
"idiom": "iphone"
},
{
"filename": "Icon@2x.png",
"size": "57x57",
"scale": "2x",
"idiom": "iphone"
},
{
"filename": "Icon-60@2x.png",
"size": "60x60",
"scale": "2x",
"idiom": "iphone"
},
{
"filename": "Icon-Small.png",
"size": "29x29",
"scale": "1x",
"idiom": "ipad"
},
{
"filename": "Icon-Small@2x.png",
"size": "29x29",
"scale": "2x",
"idiom": "ipad"
},
{
"filename": "Icon-Spotlight-40.png",
"size": "40x40",
"scale": "1x",
"idiom": "ipad"
},
{
"filename": "Icon-Spotlight-40@2x.png",
"size": "40x40",
"scale": "2x",
"idiom": "ipad"
},
{
"filename": "Icon-Small-50.png",
"size": "50x50",
"scale": "1x",
"idiom": "ipad"
},
{
"filename": "Icon-Small-50@2x.png",
"size": "50x50",
"scale": "2x",
"idiom": "ipad"
},
{
"filename": "Icon-72.png",
"size": "72x72",
"scale": "1x",
"idiom": "ipad"
},
{
"filename": "Icon-72@2x.png",
"size": "72x72",
"scale": "2x",
"idiom": "ipad"
},
{
"filename": "Icon-76.png",
"size": "76x76",
"scale": "1x",
"idiom": "ipad"
},
{
"filename": "Icon-76@2x.png",
"size": "76x76",
"scale": "2x",
"idiom": "ipad"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.0 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.4 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 8.0 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.5 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 8.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.4 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.3 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.0 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.5 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.8 KiB

Просмотреть файл

@ -0,0 +1,148 @@
{
"images": [
{
"minimum-system-version": "7.0",
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default@2x.png",
"size": "640x960",
"scale": "2x",
"idiom": "iphone"
},
{
"minimum-system-version": "7.0",
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-568h@2x.png",
"size": "640x1136",
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"minimum-system-version": "7.0",
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-Portrait~ipad.png",
"size": "768x1024",
"scale": "1x",
"idiom": "ipad"
},
{
"minimum-system-version": "7.0",
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-Portrait@2x~ipad.png",
"size": "1536x2048",
"scale": "2x",
"idiom": "ipad"
},
{
"minimum-system-version": "7.0",
"orientation": "landscape",
"extent": "full-screen",
"filename": "Default-Landscape~ipad.png",
"size": "1024x768",
"scale": "1x",
"idiom": "ipad"
},
{
"minimum-system-version": "7.0",
"orientation": "landscape",
"extent": "full-screen",
"filename": "Default-Landscape@2x~ipad.png",
"size": "2048x1536",
"scale": "2x",
"idiom": "ipad"
},
{
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default.png",
"size": "320x480",
"scale": "1x",
"idiom": "iphone"
},
{
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default@2x.png",
"size": "640x960",
"scale": "2x",
"idiom": "iphone"
},
{
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-568h@2x.png",
"size": "640x1136",
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-Portrait~ipad.png",
"size": "768x1024",
"scale": "1x",
"idiom": "ipad"
},
{
"orientation": "portrait",
"extent": "full-screen",
"filename": "Default-Portrait@2x~ipad.png",
"size": "1536x2048",
"scale": "2x",
"idiom": "ipad"
},
{
"orientation": "portrait",
"extent": "to-status-bar",
"size": "768x1004",
"scale": "1x",
"idiom": "ipad"
},
{
"orientation": "portrait",
"extent": "to-status-bar",
"size": "1536x2008",
"scale": "2x",
"idiom": "ipad"
},
{
"orientation": "landscape",
"extent": "full-screen",
"filename": "Default-Landscape~ipad.png",
"size": "1024x768",
"scale": "1x",
"idiom": "ipad"
},
{
"orientation": "landscape",
"extent": "full-screen",
"filename": "Default-Landscape@2x~ipad.png",
"size": "2048x1536",
"scale": "2x",
"idiom": "ipad"
},
{
"orientation": "landscape",
"extent": "to-status-bar",
"size": "1024x748",
"scale": "1x",
"idiom": "ipad"
},
{
"orientation": "landscape",
"extent": "to-status-bar",
"size": "2048x1496",
"scale": "2x",
"idiom": "ipad"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 61 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 22 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 28 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 21 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 42 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 14 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 38 KiB

Просмотреть файл

@ -0,0 +1,37 @@
QuickContacts
==============
QuickContacts demonstrates how to use the Address Book UI controllers and various properties such as `DisplayedProperties` and `allowsAddingToAddressBook`
This sample also shows how to
-----------------------------
* Browse a list of Address Book contacts and allow users to choose a contact from that list.
* Display and edit information associated with a selected contact.
* Prevent users from performing default actions such as dialing a phone number associated with a selected information.
* Create a new contact record.
* Update a partial contact record.
* Present and dismiss the people picker, person view controller, new-person view controller, and unknown-person view controller.
Instructions
------------
The application displays four cells labeled `Display Picker`, `Create New Contact`, `Display and Edit Contact`, and `Edit Unknown Contact`.
* Tap "Display Picker" to browse a list of contacts and choose a person from that list.
* Tap "Create New Contact" to create a new person.
* Tap "Display and Edit Contact" to display and edit a person.
* Tap "Edit Unknown Contact" to add data to an existing person or use them to create a new person.
Build Requirements
------------------
Building this sample requires Xcode 6.0 and iOS 8.0 SDK
Target
------
This sample runnable on iPhoneSimulator/iPadSimulator iPhone/iPad
Author
------
Copyright (C) 2014 Apple Inc. All rights reserved.
Ported to Xamarin.iOS by Rustam Zaitov

Двоичные данные
ios8/QuickContacts/Screenshots/iPad/CreateNewContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 177 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPad/DisplayAndEditContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 79 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPad/DisplayPicker.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 100 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPad/EditUnknownContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 90 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPad/MainScreen.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 91 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPhone/CreateNewContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 86 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPhone/DisplayAndEditContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 64 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPhone/DisplayPicker.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 114 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPhone/EditUnknownContact.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 89 KiB

Двоичные данные
ios8/QuickContacts/Screenshots/iPhone/MainScreen.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 97 KiB