我正在使用联系人UI添加新的联系人与此代码
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)我想让导航栏的标题是"AppContact“,但它总是得到默认的”新联系人“。如何更改标题?
发布于 2016-08-03 18:43:46
导航栏从当前位于导航堆栈顶部的UIViewController (在本例中为RootViewController )获取标题。而是更改该UIViewController的title属性
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类参考中对的title属性的讨论
讨论:
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.
UIViewController标题文档的Link。
https://stackoverflow.com/questions/38741013
复制相似问题