次のコードは iOS7 では正しく動作しますが、iOS8 では動作しません (変数recordID
が正しく設定されています)。
CFErrorRef error = nil;
const ABAddressBookRef addressBook = (ABAddressBookCreateWithOptions (NULL, &error));
ABRecordRef contactRef = ABAddressBookGetPersonWithRecordID (addressBook, recordID);
ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.addressBook = addressBook;
personViewController.displayedPerson = contactRef;
CFRelease(addressBook);
NSArray *displayedProperties = @[@(kABPersonFirstNameProperty),
@(kABPersonLastNameProperty),
@(kABPersonMiddleNameProperty),
@(kABPersonPrefixProperty),
@(kABPersonSuffixProperty),
@(kABPersonOrganizationProperty),
@(kABPersonJobTitleProperty),
@(kABPersonDepartmentProperty),
@(kABPersonEmailProperty),
@(kABPersonBirthdayProperty),
@(kABPersonKindProperty),
@(kABPersonAddressProperty),
@(kABPersonPhoneProperty),
@(kABPersonInstantMessageProperty),
@(kABPersonURLProperty),
@(kABPersonSocialProfileProperty),
@(kABPersonNoteProperty)];
personViewController.displayedProperties = displayedProperties;
personViewController.navigationItem.title = NSLocalizedString(@"CONTACT_DETAILS", nil);
personViewController.allowsActions = YES;
personViewController.allowsEditing = YES; // if NO, no back button is shown
personViewController.personViewDelegate = self;
personViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"ADDRESSES",nil) style:UIBarButtonItemStylePlain target:self action:@selector(personviewDoneButtonPressed:)];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:personViewController];
[self presentViewController:navigationController animated:YES completion:nil];
iOS8 のバグ:
- をに
allowsEditing
設定するYES
と、連絡先は 表示されますが、名前のみが表示されます。ナビゲーション バーには、左側に [戻る] ボタン ("Addresses" という名前)、右側に編集ボタンが表示されます。編集ボタンを押すと、 name 以外のすべてのフィールドが空の連絡先が表示され、編集ボタンが完了ボタンとして表示されます。前に編集せずにこの完了ボタンを押すと、連絡先に関するすべての情報が表示されます。 - をに
allowsEditing
設定するNO
と、戻るボタンが表示されなくなり、画面を離れることができなくなります。
誰にも回避策はありますか?
アップデート:
私は今、問題1がシミュレーターでのみ発生することに気付きましたが、常に私のデバイスで発生します。