ios - 如何告诉按钮不要继续,但在 Storyboard 中仍然有继续

标签 ios objective-c segue

有没有办法让按钮不转场但 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/

相关文章:

ios - 如何更改状态背景以不同于 iOS 7 上的导航栏?

iphone - 如何在 Xcode 4 上处理 Info.plist 的 "Clear File History"?

objective-c - 如何在 Objective C 中舍入 Decimal 值

ios - prepareForSegue :sender: fails to alter property on destination VC

swift - Facebook 在 tvOS 上登录失败后继续

ios - 创建约束以在以编程方式调整大小的 View 上重新定位按钮

ios - 使用 xCode 创建应用程序 ID

ios - iOS6 中的 UISegmentedControl 图像突出显示错误

ios - 偶尔从NSDateFormatter返回零

ios - Swift 准备被 TabBarController 打断的 segue