Pop the current view using Segues/Storyboard on iOS 5

后端 未结 5 591
陌清茗
陌清茗 2020-12-08 11:15

I am creating an app using iOS 5 SDK. I managed to push views using the Storyboard\'s Segues, but I cannot find the proper way to pop the current view and go back to the pre

5条回答
  •  甜味超标
    2020-12-08 11:52

    Storyboards in iOS 5 don't provide a "no-code" way to return from a segue -- that's something you'll need to implement yourself.

    If you use "push" segues (which require a navigation controller), use the navigation controller's popViewControllerAnimated: method to undo the last push segue. (Or other methods to undo more; see the UINavigationController documentation.)

    If you use "modal" segues, call dismissViewControllerAnimated:completion: on the view controller which presented the current view controller (which you can get from its presentingViewController property).


    Update: In iOS 6 and later there's unwind segues for going "back" in a storyboard. It's still not a no-code solution -- and it shouldn't be, because you need to be able to do things like differentiating between "Done" and "Cancel" exits from a modal view controller. But it does let you put more of the semantic flow of your app into the storyboard. Apple has a tech note that describes them in detail, and they're also covered in the video from WWDC 2012 Session 407.

提交回复
热议问题