首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改contactsUI 'forNewContact‘swift的标题

更改contactsUI 'forNewContact‘swift的标题
EN

Stack Overflow用户
提问于 2016-08-03 18:29:09
回答 1查看 479关注 0票数 2

我正在使用联系人UI添加新的联系人与此代码

代码语言:javascript
复制
        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“,但它总是得到默认的”新联系人“。如何更改标题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-03 18:43:46

导航栏从当前位于导航堆栈顶部的UIViewController (在本例中为RootViewController )获取标题。而是更改该UIViewController的title属性

代码语言:javascript
复制
    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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38741013

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档