Ish*_*ena 8 uinavigationbar uiviewcontroller uinavigationcontroller ios swift
我试图让用户创建一个新的联系人.虽然我有屏幕提示用户输入他的所有细节,但顶部没有导航栏(就像默认的Apple Contacts应用程序中一样).没有办法退出现场.我在swift 2.0和Xcode 7.3中使用了ContactUI框架.这是代码:
// create a new contact
let createNewActionHandler = {(action: UIAlertAction) -> Void in
let newContact = CNMutableContact()
let contactPicker = CNContactViewController(forNewContact: newContact)
contactPicker.delegate = self
contactPicker.navigationController?.setToolbarHidden(false, animated: false)
self.presentViewController(contactPicker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
这是我想要得到的: Apple默认
这就是我拥有的: 我拥有的
我正在选项卡视图控制器中的操作表中启动新的联系人视图控制器.我尝试在导航视图控制器中嵌入选项卡,但没有效果.我甚至尝试设置navController的setToolbarHidden属性,但它没有帮助.
谢谢你的帮助.我看到其他论坛提出的问题,但他们没有帮助.
SPa*_*tel 12
您必须将contactViewController嵌入到UINavigationController和实现委托方法中.
let createNewActionHandler = {(action: UIAlertAction) -> Void in
let newContact = CNMutableContact()
let contactPicker = CNContactViewController(forNewContact: newContact)
contactPicker.delegate = self
let navigation = UINavigationController(rootViewController: contactPicker)
self.presentViewController(navigation, animated: true, completion: nil)
}
//MARK: - Delegate
func contactViewController(viewController: CNContactViewController, didCompleteWithContact contact: CNContact?) {
viewController.dismissViewControllerAnimated(true, completion: nil)
}
func contactViewController(viewController: CNContactViewController, shouldPerformDefaultActionForContactProperty property: CNContactProperty) -> Bool {
return true
}
Run Code Online (Sandbox Code Playgroud)
小智 5
视图控制器必须嵌入在UINavigationController中,并且您应该推送或显示视图控制器:
navigationController?.pushViewController(contactPicker, animated: true)
Run Code Online (Sandbox Code Playgroud)
而不是呈现视图控制器
归档时间: |
|
查看次数: |
2367 次 |
最近记录: |