有没有办法让按钮不转场但 Storyboard中仍然有转场?我希望它不继续但在 Storyboard 中仍然有继续的原因是因为我有一个 if 语句。
最佳答案
实现shouldPerformSegueWithIdentifier:sender:
,并将条件逻辑放入其中。
假设您有一个名为 @"OnMyButton"
的 segue,但您不想在某个变量(我们称之为 count
)小于 10 时激活它。然后您可以按如下方式编写此逻辑:
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if ([identifier isEqualToString:@"OnMyButton"]) {
if (count < 10) {
// Count is too low - don't do the segue
return NO;
}
// Fall through to the default, which is YES
}
return YES;
}
关于ios - 如何告诉按钮不要继续,但在 Storyboard 中仍然有继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23644263/