gpt4 book ai didi

IOS Swift CNContactViewController 导航栏不显示 UINavigation Controller

转载 作者:行者123 更新时间:2023-11-28 06:09:52 26 4
gpt4 key购买 nike

我一直在研究这个问题,但无法解决任何问题。我有一个 View Controller ,它有效地位于主 Storyboard中。在该 View Controller 内部,当特定操作发生时将接触类型传递给该操作。

该操作为传递的联系人打开一个新的联系人 View Controller ,并允许用户根据 CNContactViewController 与联系人进行交互。一旦用户完成联系人,它将关闭,因为 didCompleteWith 方法,但没有办法退出联系人 Controller ,而不实际创建联系人。

//change to new contact screen
let con = CNMutableContact()
con.givenName = familyComponents[0]
con.familyName = familyComponents[1]

let newEmail = CNLabeledValue(label: "Personal", value: objectComponents[2]
as NSString)
con.emailAddresses.append(newEmail)
con.phoneNumbers.append(CNLabeledValue(
label: "Home", value: CNPhoneNumber(stringValue: objectComponents[3])))
let newScreen = CNContactViewController(forUnknownContact: con)
newScreen.message = "Made using app"
newScreen.contactStore = CNContactStore()
newScreen.delegate = self
newScreen.allowsActions = true
let navigationController = UINavigationController(rootViewController:
newScreen)
self.present(navigationController, animated: true, completion: nil)

我已经尝试了从 navigationItems 到 navigationItems 的一切,在我看来导航栏就在那里,因为可以用这行代码改变它的半透明性:

navigationController.navigationBar.isTranslucent = true

以下方法:

func contactViewController(_ viewController: CNContactViewController, 
didCompleteWith contact: CNContact?) {
viewController.dismiss(animated: true, completion: nil)
inContact = false
}
func contactViewController(_ shouldPerformDefaultActionForviewController:
CNContactViewController, shouldPerformDefaultActionFor property:
CNContactProperty) -> Bool {
return false
}

任何建议将不胜感激,我一直在为这个问题苦苦挣扎太久了。谢谢!

已解决:得到它的工作。事实证明这是苹果框架中的一个错误。为了解决这个问题,我只是将它从未知联系人切换到新联系人,显然没有这个错误。部分新代码:

let newScreen = CNContactViewController(forNewContact: con)
newScreen.delegate = self
let navigationController = UINavigationController(rootViewController: newScreen)
self.present(navigationController, animated: true, completion: nil)

谢谢

最佳答案

你能试试这个代码吗

let con = CNMutableContact()
con.givenName = familyComponents[0]
con.familyName = familyComponents[1]

let newEmail = CNLabeledValue(label: "Personal", value: objectComponents[2]
as NSString)
con.emailAddresses.append(newEmail)
con.phoneNumbers.append(CNLabeledValue(
label: "Home", value: CNPhoneNumber(stringValue: objectComponents[3])))
let unkvc = CNContactViewController(forUnknownContact: con)

unkvc.delegate = self
unkvc.allowsEditing = true
unkvc.allowsActions = true
unkvc.title = "Edit Contact"

self.navigationController?.isNavigationBarHidden = false

self.navigationController?.navigationItem.hidesBackButton = true

self.navigationController?.pushViewController(unkvc, animated: false)

关于IOS Swift CNContactViewController 导航栏不显示 UINavigation Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47067117/

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