想要关闭当前页面视图,返回父一级的视图:
试了很多个:
self.dismissViewControllerAnimated
和:
self.navigationController?.popViewControllerAnimated
dispatch_async(dispatch_get_main_queue(), { () -> Void in //close current view // self.dismissViewControllerAnimated(true, completion: nil) //ConversationManage vc // self.navigationController?.popViewControllerAnimated(true) //// //conversation vc //// self.navigationController?.popViewControllerAnimated(true) }) |
结果都没有达到对应效果:
点击返回后,显示的内容还是没变化
然后父一级的父一级的主视图不出现
swift close viewcontroller
ios – how to dismiss view controller in swift? – Stack Overflow
ios – dismissViewControllerAnimated() does not dismiss view controller – Stack Overflow
ios – How to dismiss the current ViewController and go to another View in Swift – Stack Overflow
how to dismiss 2 view controller in swift ios? – Stack Overflow
最后经过测试,还是之前用的pop好用:
//self quit group ok //remove conversation view (and message tableview) gConversationTVC.removeConversationItem([self.curContactItem.id]) dispatch_async(dispatch_get_main_queue(), { () -> Void in // // save the presenting ViewController // let presentingViewController :UIViewController! = self.presentingViewController // // self.dismissViewControllerAnimated(false) { // // go back to MainMenuView as the eyes of the user // presentingViewController.dismissViewControllerAnimated(false, completion: nil) // } //close current view //self.dismissViewControllerAnimated(true, completion: nil) //close manage group vc self.navigationController?.popViewControllerAnimated(true) //close group conversation vc self.navigationController?.popViewControllerAnimated(true) }) |
通过两次的:
self.navigationController?.popViewControllerAnimated(true)
退出页面,回到主界 main:
转载请注明:在路上 » [已解决]swift关闭当前页面视图返回父级视图