Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios segue "cancel"

Tags:

ios

segue

Depending on an XML return, I don't want the current segue to perform on UIButton touch.

I know I can pick which segue I want to perform, but how to I make a segue not perform? Or at least not perform any of the available segues?

like image 384
Jacksonkr Avatar asked Jan 24 '12 20:01

Jacksonkr


1 Answers

If your deployment target is iOS 6.0 or later, you can override the -[UIViewController shouldPerformSegueWithIdentifier:sender:] method to return YES if you want to perform the segue and NO if you don't.

If your deployment target is earlier than iOS 6.0, you won't receive the shouldPerformSegueWithIdentifier:sender: message. So in your storyboard, don't draw the segue from the button. Instead, draw the segue from the button's view controller and give the segue an identifier. Connect the button to an IBAction in its view controller. In the action, check whether you want to perform the segue. If you want to perform it, send yourself performSegueWithIdentifier:sender:, passing the identifier you assigned to the segue in the storyboard.

like image 119
rob mayoff Avatar answered Oct 14 '22 18:10

rob mayoff