0
新しいCNContactを作成しながら(viewControllerForNewContactメソッドを利用して)限られた数のキーしか表示しません。しかし、私が試みたキーを取り出すためのさまざまな値にもかかわらず、私はまだ設定可能な値の世界全体を取得し続けています。新しい連絡先に表示されるキーをどのように制限できますか?ヘッダファイルCNContactViewController.hで以下 viewControllerForNewContactはすべてのキーを表示します
は、これまでの私のコードですこれは、既存の連絡先のために正常に動作しているようだが、何とかない新しい連絡先のために... ...
CNMutableContact *newContact = [[CNMutableContact alloc] init];
// NSArray *keysToFetch = @[CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey, CNContactEmailAddressesKey, CNContactImageDataKey, [CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName], [CNContactViewController descriptorForRequiredKeys]];
// NSArray *keysToFetch = @[[CNContactViewController descriptorForRequiredKeys]];
// NSArray *keysToFetch = @[CNContactGivenNameKey, [CNContactViewController descriptorForRequiredKeys]];
// NSArray *keysToFetch = @[CNContactIdentifierKey, CNContactEmailAddressesKey, CNContactBirthdayKey, CNContactImageDataKey, CNContactPhoneNumbersKey, [CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName],[CNContactViewController descriptorForRequiredKeys]];
// NSArray *keysToFetch = @[[CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName], CNContactEmailAddressesKey];
NSArray *keysToFetch = @[CNContactGivenNameKey, CNContactPhoneNumbersKey];
CNContactViewController *newContactViewController = [CNContactViewController viewControllerForNewContact:newContact];
newContactViewController.delegate = self;
newContactViewController.allowsActions = YES;
newContactViewController.allowsEditing = YES;
newContactViewController.displayedPropertyKeys = keysToFetch;
UINavigationController *newContactNavViewController = [[UINavigationController alloc] initWithRootViewController:newContactViewController];
newContactNavViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:newContactNavViewController animated:YES completion:nil];