Yeni bir CNContact oluştururken sadece sınırlı sayıda tuş göstermek istiyorum (viewControllerForNewContact yöntemini kullanarak). Bununla birlikte, denediğim anahtarları getirmeye yönelik çeşitli değerlere rağmen, hala tüm değerler kümesini elde etmeye devam ediyorum. Yeni kişiler için gösterilen tuşları nasıl sınırlayabiliriz? başlık dosyasına CNContactViewController.h yılında Aşağıda viewControllerForNewContact tüm tuşları gösterir
şimdiye kadar benim kodudurBu mevcut kişiler için iyi çalışıyor gibi görünüyor, ama bir şekilde değil yeni kişiler için ... ...
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];