【问题标题】:change title for contactsUI 'forNewContact' swift快速更改contactsUI'forNewContact'的标题
【发布时间】:2016-08-03 10:29:08
【问题描述】:

我正在使用联系人 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”,但它总是得到默认的“新联系人”。怎么改标题?

【问题讨论】:

    标签: ios swift uinavigationcontroller swift3 cncontact


    【解决方案1】:

    导航栏从当前位于导航堆栈顶部的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)
    

    这是apple提供的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.

    LinkUIViewController 标题文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-12
      • 2020-11-19
      • 2015-06-11
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多