Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CNContactViewController-编辑按钮未显示_Ios_Swift_Uinavigationcontroller_Contacts_Viewcontroller - Fatal编程技术网

Ios CNContactViewController-编辑按钮未显示

Ios CNContactViewController-编辑按钮未显示,ios,swift,uinavigationcontroller,contacts,viewcontroller,Ios,Swift,Uinavigationcontroller,Contacts,Viewcontroller,我目前正在开发一个Swift应用程序,我希望用户能够编辑他们之前在应用程序中创建的联系人。也就是说,我正在使用CNContactViewController(forContact:CNContact)init函数来创建视图控制器 我在TableViewController的子类中有以下代码,该子类嵌入在导航控制器中 let contactViewController = CNContactViewController(forNewContact: contact) contactViewCont

我目前正在开发一个Swift应用程序,我希望用户能够编辑他们之前在应用程序中创建的联系人。也就是说,我正在使用
CNContactViewController(forContact:CNContact)
init函数来创建视图控制器

我在
TableViewController
的子类中有以下代码,该子类嵌入在导航控制器中

let contactViewController = CNContactViewController(forNewContact: contact)
contactViewController.delegate = self
self.navigationController?.pushViewController(contactViewController, animated: true)
contactViewController
进入视图时,触点加载正常,但顶部导航栏中缺少编辑按钮。如果我在将其推送到导航控制器之前立即硬编码
打印(contactViewController.allowsdedits)
,它会显示true,这很奇怪

谢谢你的帮助


(注意,我传递给构造函数的联系人是一个
CNMutableContact
,因此它应该是可编辑的)

在按下contactViewController之前,您应该只添加此项以显示“编辑”按钮:

let contactViewController = CNContactViewController(forNewContact: contact)
contactViewController.delegate = self

//Here you make Edit button to appear and do things that it is supposed to do
contactViewController.navigationItem.rightBarButtonItem? = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Edit,target: self, action: nil)

self.navigationController?.pushViewController(contactViewController, animated: true)

不要推它,而是尝试在它自己的导航控制器中显示它。