gpt4 book ai didi

ios - 更改 contactsUI 的标题 'forNewContact' swift

转载 作者:搜寻专家 更新时间:2023-11-01 07:21:28 25 4
gpt4 key购买 nike

我正在使用联系人 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”,但它总是获得默认的“New Contact”。如何更改标题?

最佳答案

导航栏从目前位于导航堆栈顶部的 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属性的讨论

讨论:

将标题设置为描述 View 的人类可读字符串。如果 View Controller 具有有效的导航项或选项卡栏项,则为该属性赋值会更新这些对象的标题文本。

LinkUIViewController 标题文档。

关于ios - 更改 contactsUI 的标题 'forNewContact' swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38741013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com