简体   繁体   中英

dealing with modal segues between viewcontrollers in a storyboard

I have an iPad application in a storyboard board (in xcode) with a few separate view controllers. I have to have them setup using modal segues to transition between each other. I was wondering what the best approach is in dealing with dimissing viewcontrollers after performing a segue. Should you dismiss the previous view controller after a successful segue? And if so which way is optimal?

If base view controller A presents view controller B as a modal, and then you need modal C to appear, you should dismiss modal B before presenting C. This assumes the task in modal B does not depend on the result of user action in C

You can achieve a smooth transition between dismissing B and presenting C with:

// instantly dismiss B (or whichever is showing)
[self dismissModalViewControllerAnimated:NO];
// show the other modal with your existing segue
[self performseguewithidentifier@"c_segue"];

From a UI design perspective, modals are for an interruption / interaction that the user must deal with while performing a task on another view controller (A in your case). If the interaction in modal B requires another such interruption (meaning B must present C as a modal) it's time to look at your UI design and see if what you are doing is the best approach.

If you are actually moving between views (you don't want A around any more) then a modal is definitely the wrong choice. You probably want to do a replace seque, or look into a ContainerView for managing swapping out view controllers.

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