How to check if a view controller can perform a segue

前端 未结 8 2001
长发绾君心
长发绾君心 2020-12-29 02:10

This might be a very simple question but didn\'t yield any results when searching for it so here it is...

I am trying to work out a way to check if a certain view co

8条回答
  •  清酒与你
    2020-12-29 02:58

    You can override the -(BOOL)shouldPerformSegueWithIdentifier:sender: method and do your logic there.

    - (BOOL) shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
        if ([identifier isEqualToString:@"someSegue"]) {
            if (!canIPerformSegue) {
                return NO;
            }
        }
        return YES;    
    }
    

    Hope this helps.

提交回复
热议问题