从xcode中的另一个视图控制器禁用按钮

时间:2012-11-02 23:58:31

标签: ios xcode uiviewcontroller uibutton

我有一个动态初始化的按钮。我想从另一个UIViewController中禁用该按钮。

我正在使用此代码:

按钮是     @property(强,非原子)IBOutlet UIButton * aboutus;

然后我尝试以这种方式禁用它:

OtherViewController * view2 = [[OtherViewController alloc]      initWithNibName:@"view2"    bundle:nil];
view2.aboutus.enabled=NO;

但按钮仍然会启用..任何想法为什么?

1 个答案:

答案 0 :(得分:1)

您需要公开BOOL财产:

@property(nonatomic) buttonEnabled;
<{1>} OtherViewController。将该值设置为您想要的值(是或否),然后在viewDidLoad:

aboutus.enabled = buttonEnabled;
相关问题