我希望找到一种方法,如果用户在
我希望能够像这样做某事:
ABPeoplePickerNavigationController
中按下“取消”按钮(我认为无法删除),则视图控制器要么不关闭,要么将自动重新打开。例如,给定以下内容:var picker = ABPeoplePickerNavigationController()
picker.peoplePickerDelegate = self
self.presentViewController(picker, animated: true, completion: nil)
我希望能够像这样做某事:
if (self.presentedViewController != picker && !userContinuedPastPicker) {
//where userContinuedPastPicker is a boolean set to false
//in a delegate method called when the user clicks on an a contact
//(meaning the user didn't press the cancel button but instead clicked on a contact)
//create and present a UIAlertAction informing the user they must select a contact
//present picker again
self.presentViewController(picker, animated: true, completion: nil)
}
这种方法行不通,因为if
语句不会等待用户按下取消按钮或联系人。
ABPPNC
或UIAlertController
实例(正如您所建议的那样),我会收到一个错误,提示:警告:尝试在未在窗口层次结构中的 <App.FirstViewController: 0x7a06dd30> 上呈现 <UIAlertController: 0x7a0cfc50>!
- Randoms