ios - 禁用和隐藏 UIButton/UIBarButtonItem 的理想方法是什么?

标签 ios interface-builder storyboard

在我的应用程序中,如果第一次运行或用户已清除其登录凭据,则会以模态方式呈现一个 View ,他们可以在其中登录。如果他们希望切换帐户,他们还可以选择显示登录 View 。但是,我还希望他们能够在错误地点击“切换帐户”按钮时使用“取消”按钮关闭此 View ,但如果应用程序是第一次运行,则不能。

我知道我可以通过在代码中创建一个 UIBarButtonItem 并设置其 hiddenenabled 属性来做到这一点,但想知道它是否是可以使用 Storyboard和 socket 。有什么建议吗?

最佳答案

当然你可以做到。您只需将隐藏或启用的消息发送到 socket 即可。因此,如果您有一个名为 myButton 的 IBOutlet 连接到 IB 中的按钮,则可以编写:

myButton.hidden = YES;

关于ios - 禁用和隐藏 UIButton/UIBarButtonItem 的理想方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14181428/

相关文章:

ios - MPMoviePlayerViewController 状态栏不隐藏

ios - 如何让textField验证代码更加紧凑和可读?

ios - 在数组数组中查找值

ios - 如何使用单独的 Storyboard以编程方式正确设置 UITabBarController

ios - 在 StoryBoard 的 TabController 内部使用 Navigation。

ios - [AnyObject] ?' does not have a member named ' 下标'

iphone - IBOutletColletion 的实际有效使用

ios - 在 initWithCoder : what are the keys in the NSCoder (a UINibDecoder)?(用于 UIImageView)

ios - 如何以编程方式设置图层?

ios - 将背景图像缩放到 iPhone 10