最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift关闭当前页面视图返回父级视图

Swift crifan 4683浏览 0评论

想要关闭当前页面视图,返回父一级的视图:

试了很多个:

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关闭当前页面视图返回父级视图

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
86 queries in 0.183 seconds, using 22.06MB memory