In this recipe, we will learn how to use the native address book user interface to display contact information.
Perform the following steps:
Add a button on the controller.
In the
AppDelegate.cs
file, add theDisplayContactAppViewController
to a navigation controller, as follows:window.RootViewController = new UINavigationController(viewController);
Add the following namespaces in the
DisplayContactAppViewController.cs
file:using MonoTouch.AddressBook; using MonoTouch.AddressBookUI;
Add the following code in the
ViewDidLoad
method:this.btnDisplayContact.TouchUpInside += (sender, e) => { ABAuthorizationStatus status = ABAddressBook.GetAuthorizationStatus(); NSError error; ABAddressBook addressBook = ABAddressBook.Create(out error); if (status == ABAuthorizationStatus.NotDetermined) { addressBook.RequestAccess((g, err) => { if (g) ...