2016-03-23 8 views
0

Ich möchte nur eine begrenzte Anzahl von Schlüsseln anzeigen, während ich einen neuen CNContact erzeuge (Nutzung der Methode viewControllerForNewContact). Trotz der verschiedenen Werte für die Schlüssel, die ich ausprobiert habe, bekomme ich immer noch das gesamte Universum der einstellbaren Werte. Wie können wir die Schlüssel begrenzen, die für neue Kontakte angezeigt werden?viewControllerForNewContact zeigt alle Schlüssel an

Dies scheint für bestehende Kontakte funktioniert gut werden, aber irgendwie nicht für neue Kontakte ...

Unter meinen Code so weit ... ist

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]; 

Antwort

0

In der Header-Datei CNContactViewController.h Es gibt eine Notiz, die besagt: "Alle Eigenschaften sind sichtbar, wenn der Kontakt bearbeitet wird". Also ich denke, es ändert nichts, um displayedPropertyKeys für einen neuen Kontakt festzulegen, da es im Bearbeitungsmodus angezeigt wird.