Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What worked for me and what I believe to be the correct answer is to use UIViewController method found in <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="noreferrer">Apple Developer Guide</a>:</p> <p><em>shouldPerformSegueWithIdentifier:sender:</em></p> <p>I implemented my method like so:</p> <pre><code>- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { if ([identifier isEqualToString:@"Identifier Of Segue Under Scrutiny"]) { // perform your computation to determine whether segue should occur BOOL segueShouldOccur = YES|NO; // you determine this if (!segueShouldOccur) { UIAlertView *notPermitted = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Segue not permitted (better message here)" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; // shows alert to user [notPermitted show]; // prevent segue from occurring return NO; } } // by default perform the segue transition return YES; } </code></pre> <p>Worked like a charm!</p> <hr> <p><strong>Updated with Swift for >= iOS 8</strong>:</p> <pre><code>override func shouldPerformSegueWithIdentifier(identifier: String!, sender: AnyObject!) -&gt; Bool { if identifier == "Identifier Of Segue Under Scrutiny" { // perform your computation to determine whether segue should occur let segueShouldOccur = true || false // you determine this if !segueShouldOccur { let notPermitted = UIAlertView(title: "Alert", message: "Segue not permitted (better message here)", delegate: nil, cancelButtonTitle: "OK") // shows alert to user notPermitted.show() // prevent segue from occurring return false } } // by default perform the segue transitio return true } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload