0
我有困難與一個UI按鈕的數組,而不是有許多單獨的。我試圖創建四個有:目標C數組UIButtons(包括照顧初始化,動作等)
ViewController.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
IBOutlet UIButton *b0;
IBOutlet UIButton *b1;
IBOutlet UIButton *b2;
IBOutlet UIButton *b3;
}
@property (nonatomic, strong) UIButton *b0;
@property (nonatomic, strong) UIButton *b1;
@property (nonatomic, strong) UIButton *b2;
@property (nonatomic, strong) UIButton *b3;
@end
ViewController.m:
- (IBAction)b0Click:(id)sender {
//Do something
}
- (IBAction)b1Click:(id)sender {
//Do something
}
- (IBAction)b2Click:(id)sender {
//Do something
}
- (IBAction)b3Click:(id)sender {
//Do something
}
任何幫助,將不勝感激。謝謝!
你沒有描述問題(數組在哪裏?它有什麼作用?)。你看過'IBOutletCollection'嗎? – Wain
您是否試圖從界面構建器創建它們?如果是這樣,你不會創建指向你的引用的網點。同時檢查出'IBOutletCollection'。 – jervine10