зеркало из https://github.com/xamarin/ios-samples.git
Add call to RequestAccess so the sample works on iOS 6.0+ devices (check not enforced on the simulator). Fix bug #11618
This commit is contained in:
Родитель
2a17e76461
Коммит
c366b0e0bd
|
@ -29,6 +29,8 @@ namespace Example_SharedResources.Screens.iPhone.Contacts
|
|||
/// </summary>
|
||||
RectangleF contentViewSize = RectangleF.Empty;
|
||||
|
||||
ABAddressBook addressBook;
|
||||
|
||||
#region Constructors
|
||||
|
||||
// The IntPtr and initWithCoder constructors are required for items that need
|
||||
|
@ -85,12 +87,20 @@ namespace Example_SharedResources.Screens.iPhone.Contacts
|
|||
// neccessary to access each item
|
||||
|
||||
// instantiate a reference to the address book
|
||||
using(ABAddressBook addressBook = new ABAddressBook ()) {
|
||||
NSError err;
|
||||
addressBook = ABAddressBook.Create (out err);
|
||||
if (err != null)
|
||||
return;
|
||||
|
||||
// if you want to subscribe to changes
|
||||
addressBook.ExternalChange += (object sender, ExternalChangeEventArgs e) => {
|
||||
// code to deal with changes
|
||||
};
|
||||
// if you want to subscribe to changes
|
||||
addressBook.ExternalChange += (object sender, ExternalChangeEventArgs e) => {
|
||||
// code to deal with changes
|
||||
};
|
||||
|
||||
addressBook.RequestAccess (delegate (bool granted, NSError error) {
|
||||
|
||||
if (!granted || error != null)
|
||||
return;
|
||||
|
||||
// for each record
|
||||
foreach(ABRecord item in addressBook) {
|
||||
|
@ -115,7 +125,7 @@ namespace Example_SharedResources.Screens.iPhone.Contacts
|
|||
//addressBook.Save();
|
||||
// or cancel them
|
||||
//addressBook.Revert();
|
||||
}
|
||||
});
|
||||
//====
|
||||
#endregion
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче