ios - 发生某些情况时如何停止插入segue?
<p><p>当某些条件失败时如何停止推送 segue </p>
<pre><code>-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
internet *myclass = [init];
if () {
if ([ isEqualToString:@"showShoping"]) {
_pass = @"shop";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
if ([ isEqualToString:@"showTravel"]) {
_pass = @"travel";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
if ([ isEqualToString:@"showFood"]) {
_pass = @"food";
MyTabController *mvc = (MyTabController *)segue.destinationViewController;
mvc.myCategory = _pass;
}
else{
UIAlertView *alert = [ initWithTitle:@"No Internet!"
message:@"No working internet connection is found."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
;
}
}
</code></pre>
<p>谢谢</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender NS_AVAILABLE_IOS(6_0);
</code></pre>
<p>你可以重写这个方法,当某些情况发生时,返回 No 停止执行 segue。</p>
<p><strong>例如</strong></p>
<pre><code>- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if () {
return NO;
}
return YES;
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 发生某些情况时如何停止插入segue?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34893421/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34893421/
</a>
</p>
页:
[1]