2016-08-03 35 views
1

ich Kontakte UI zum Hinzufügen neuen Kontakts mit diesem Codeändern Titel für contactsUI ‚forNewContact‘ swift

 let a = CNContact() 
     let contactPickerViewController = CNContactViewController.init(forNewContact: a) // iOS Editor 
     contactPickerViewController.delegate = self 
     let nav = UINavigationController.init(rootViewController: contactPickerViewController) 
     nav.title = "AppContact" 
     self.present(nav, animated: true, completion: nil) 

Ich mag die Navigationsleiste Titel machen „AppContact“ zu sein, aber es kommt immer den Standard "Neuer Kontakt". Wie ändere ich den Titel?

Antwort

2

Die Navigationsleiste packt den Titel aus der UIViewController, die derzeit auf dem Navigationsstapel ist, In Ihrem Fall die RootViewController. Statt die Eigenschaft, dass diese

let a = CNContact() 
    let contactPickerViewController = CNContactViewController.init(forNewContact: a) // iOS Editor 
    contactPickerViewController.delegate = self 
    let nav = UINavigationController.init(rootViewController: contactPickerViewController) 
    contactPickerViewController.title = "AppContact" //Using currently presented ViewController .title property. 
    self.present(nav, animated: true, completion: nil) 

UIViewController Titel ändern ist die Diskussion über die title Eigenschaft von der UIViewController Klassenreferenz von Apple bereitgestellten

Diskussion:

Set the title to a human-readable string that describes the view. If the view controller has a valid navigation item or tab-bar item, assigning a value to this property updates the title text those objects.

Link zu UIViewController Titel Dokumentation.