I display an UIAlertController when my image is downloading. When the downloading is finished, I want to push a view controller. I have an error in the console, because I don't dismiss the alert controller :
pushViewController:animated: called on <UINavigationController 0x7fb190c6ee00> while an existing transition or presentation is occurring; the navigation stack will not be updated.
In my main view controller, when the downloading is finished, I push another view :
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//....
var alert = UIAlertController(title: "Alert", message: text, preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
dispatch_async(dispatch_get_main_queue(), {
if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) {
self.performSegueWithIdentifier("postview", sender: self)
}
})
}
I tried wit dismissViewControllerAnimated but I have exactly the same error :
dispatch_async(dispatch_get_main_queue(), {
if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) {
alert.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("postview", sender: self)
}
})
To dismiss an action sheet, simulate a touch on its Cancel item. To do this, use the TouchItem method of the iOS ActionSheet test object that TestComplete associates with the control. This method simulates a single short touch on the specified item.
You can dismiss the alert by calling dismissViewControllerAnimated method on alertController object. Save this answer.
1. From the Alerts tab, under Alerts, click Inbox. 2. On the Alerts Inbox page, click the check boxes in front of the alerts you want to dismiss, then click the Dismiss button.
Step 1 − Open Xcode and create a single view application and name it UIAlertSample. So basically, when we tap on the button an alert will be displayed, when the user taps outside the alert the alert will be dismissing.
You should not call performSegueWithIdentifier
before the previous view controller has been dismissed. To time this correctly, do it from the completion handler:
dispatch_async(dispatch_get_main_queue(), {
if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) {
alert.dismissViewControllerAnimated(true, completion: {
self.performSegueWithIdentifier("postview", sender: self)
})
}
})
Now the call to perform segue would not start until the dismissal is over, preventing the error that you see.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With