cmi*_*mii 5 ios swift uialertcontroller
我的图像下载时显示UIAlertController.下载完成后,我想推送一个视图控制器.我在控制台中有错误,因为我没有关闭警报控制器:
pushViewController:animated: called on <UINavigationController 0x7fb190c6ee00> while an existing transition or presentation is occurring; the navigation stack will not be updated.
Run Code Online (Sandbox Code Playgroud)
在我的主视图控制器中,当下载完成时,我推送另一个视图:
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)
}
})
}
Run Code Online (Sandbox Code Playgroud)
我尝试过dismissViewControllerAnimated,但我有完全相同的错误:
dispatch_async(dispatch_get_main_queue(), {
if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) {
alert.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("postview", sender: self)
}
})
Run Code Online (Sandbox Code Playgroud)
das*_*ght 10
performSegueWithIdentifier在上一个视图控制器被解除之前,您不应该打电话.要正确计时,请从完成处理程序执行此操作:
dispatch_async(dispatch_get_main_queue(), {
if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) {
alert.dismissViewControllerAnimated(true, completion: {
self.performSegueWithIdentifier("postview", sender: self)
})
}
})
Run Code Online (Sandbox Code Playgroud)
现在执行segue的调用在解雇结束之前不会启动,从而防止您看到的错误.
| 归档时间: |
|
| 查看次数: |
6379 次 |
| 最近记录: |