【发布时间】:2012-10-23 16:01:37
【问题描述】:
我有一个动态初始化的按钮。我想从另一个 UIViewController 禁用该按钮。
我正在使用此代码:
按钮是 @property(强,非原子)IBOutlet UIButton *aboutus;
然后我尝试以这种方式禁用它:
OtherViewController * view2 = [[OtherViewController alloc] initWithNibName:@"view2" bundle:nil];
view2.aboutus.enabled=NO;
但该按钮仍会启用.. 任何想法为什么?
【问题讨论】:
-
按钮尚未加载,因为视图尚不存在。它将加载到 OtherViewController 的 viewDidLoad 中。这就是为什么您需要设置一个标志,然后使用该标志来禁用 viewDidLoad 中的按钮,正如 EIJay 所说。
-
有道理感谢您的帮助
标签: ios xcode uiviewcontroller uibutton