[英]disable button from another view controller in xcode
我有一個動態初始化的按鈕。我想從另一個UIViewController禁用該按鈕。
我正在使用此代碼:
該按鈕是@property(強原子)IBOutlet UIButton * aboutus;
然后我嘗試以這種方式禁用它:
OtherViewController * view2 = [[OtherViewController alloc] initWithNibName:@"view2" bundle:nil];
view2.aboutus.enabled=NO;
但該按鈕仍會啟用。.為什么有任何想法?
您需要一個公共BOOL
屬性:
@property(nonatomic) buttonEnabled;
在OtherViewController
。 將該值設置為所需的值(是或否),然后在viewDidLoad中:
aboutus.enabled = buttonEnabled;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.