无法关闭 CNContactViewController [英] Unable to dismiss CNContactViewController

查看:18
本文介绍了无法关闭 CNContactViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让用户创建新联系人.虽然我有屏幕提示用户输入他的所有详细信息,但顶部没有导航栏(就像在默认的 Apple 通讯录应用程序中一样).没有办法退出现场.我在 swift 2.0 和 Xcode 7.3 中使用 ContactUI 框架.代码如下:

I'm trying to let the user create a new contact. While I've got the screen to prompt the user to put in all his details there is no navigation bar at the top(Like there is in the default Apple Contacts app). There is no way to exit the scene. I'm using the ContactUI framework in swift 2.0 and Xcode 7.3. Here's the code:

// 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)

    }

这是我想要得到的:苹果默认

这是我所拥有的:我有什么

我正在从选项卡视图控制器中的操作表启动新的联系人视图控制器.我尝试将选项卡嵌入到导航视图控制器中,但没有效果.我什至尝试设置 navController 的 setToolbarHidden 属性,但没有帮助.

I'm launching the new contact view controller from an action sheet in a tab view controller. I tried embedding the tab in a Navigation view controller but to no effect. I even tried setting the setToolbarHidden property of the navController but it didn't help.

感谢您的帮助.我在其他论坛上看到了这个问题,但他们没有帮助.

Thanks for any help. I saw the issue raised in other forums but they didn't help.

推荐答案

视图控制器必须嵌入到 UINavigationController 中,你应该推送或显示视图控制器:

The view controllers must be embedded in UINavigationController and you should push or show view controller:

navigationController?.pushViewController(contactPicker, animated: true)

而不是呈现视图控制器

这篇关于无法关闭 CNContactViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆