ios - 如何禁用多个按钮?

标签 ios objective-c cocoa-touch uibutton

我的 View 上有 2 个按钮,我想在单击另一个按钮时禁用第一个按钮,并在再次单击该按钮时禁用第二个按钮。

我试过这个代码

if (button1.enable = NO) {
    button2.enable = NO;
}

所以我在 NavigationBar 中有一个“+”按钮和 5 个禁用按钮。
当我按下“+”按钮时,我想启用第一个按钮,当我再次按下启用第二个按钮时……
谢谢

最佳答案

if (button1.enabled == YES)
{
     button1.enabled = NO;
     button2.enabled = YES;
}
else (button2.enabled == YES)
{
     button2.enabled = NO;
     button1.enabled = YES;
}

那是你要找的吗?这将是另一个按钮的 IBAction。

关于ios - 如何禁用多个按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3489030/

相关文章:

ios - 滚动后 UICollectionView 不会保持选中状态

ios - UIView 上的圆角仅适用于 iPhone 8、iPhone 6s、iPhone 6s plus、iPhone 6 等少数模拟器

加载另一个 Nib 时的 iOS 自动布局

ios - 显示 UIAlertController 时出现 UIViewControllerHierarchyInconsistency 异常

ios - 亚马逊 Cognito iOS

iphone - 使用 MFMailComposeViewController 的问题

ios - 采取一定数量的步骤后通知。 swift 2.0

ios - iOS 6 中的定位服务无法运行

ios - 如何在不跳过的情况下在特定 anchor 旋转图层?

ios - 关闭模态视图 Controller 堆栈