I'd like to figure out a way so that, if the user presses the "Cancel" button (which I don't believe can be removed) in an ABPeoplePickerNavigationController
, the view controller either doesn't close, or will be automatically reopened.
For example, given the following:
var picker = ABPeoplePickerNavigationController()
picker.peoplePickerDelegate = self
self.presentViewController(picker, animated: true, completion: nil)
I'd like to be able to do something like:
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)
}
This doesn't work; however, because the if
statement won't "wait" until the user has pressed the cancel button or pressed a contact.
ABPPNC
or aUIAlertController
(as you so wisely suggested), I get an error saying:Warning: Attempt to present <UIAlertController: 0x7a0cfc50> on <App.FirstViewController: 0x7a06dd30> whose view is not in the window hierarchy!
– Koster