简体   繁体   中英

iOS dismiss a view controller and present another one without show the base view controller

I have 3 view controllers, vc1, vc2, vc3.

vc1 presents vc2 and vc3.

In vc1 I have the delegate method to dismiss vc2 and in the completion block present vc3.

It works fine. But in between the switch of views, vc1 will show. so vc2 dismiss, vc1 show, vc3 show up.

Is there any way not to show vc1 in the process? I tried to dismiss animation in both dismiss and present.

Thanks!

One idea might be to just present vc3 on top of vc2. Once you're ready to go back to vc1, just call [self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; and you'll pop both vc2 and vc3 without seeing vc2.

One technique is to use UINavigationController's setViewControllers:animated method. Grab the viewControllers array from the nav controller, remove the last item (VC2), append VC3, then pass the array in to setViewControllers . This is essentially a pop-then-push, and it should animate the way you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM