当某些条件失败时如何停止推送segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
internet *myclass = [[internet alloc]init];
if ([myclass connectedToInternet]) {
if ([[segue identifier] isEqualToString:@"showShoping"]) {
_pass = @"shop";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
if ([[segue identifier] isEqualToString:@"showTravel"]) {
_pass = @"travel";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
if ([[segue identifier] isEqualToString:@"showFood"]) {
_pass = @"food";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet!"
message:@"No working internet connection is found."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
谢谢
最佳答案
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender NS_AVAILABLE_IOS(6_0);
您可以重写此方法,当某些情况发生时返回No以停止执行segue。
例如
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if ([identifier isEqualToString:@"showShoping" ]) {
return NO;
}
return YES;
}
}
关于ios - 当某些情况发生时如何停止插入segue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34893421/