【发布时间】:2013-03-28 19:00:40
【问题描述】:
正如标题所说,我的 UIButtons 的 IBOutletCollection 在 viewDidLoad 之后是空的。 我以同样的方式创建了一个 UILabels 的 IBOutletCollection,这个工作得很好。 知道如何解决这个问题,或者我在哪里犯了错误?
代码如下:
@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *lbl_save;
@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *lbl_cancel;
@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *lbl_edit;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btn_changeData;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btn_save;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btn_cancel;
按钮放置在 xib 中并正确链接到相应的插座。就像标签一样。
我第一次按下按钮时,我想访问代码中的按钮。
for (UIButton *btn in _btn_changeData) {
btn.hidden = NO;
btn.userInteractionEnabled = YES;
}
for (UIButton *btn in _btn_save) {
btn.hidden = YES;
btn.userInteractionEnabled = NO;
}
for (UIButton *btn in _btn_cancel) {
btn.hidden = YES;
btn.userInteractionEnabled = NO;
}
for (UILabel *lbl in _lbl_save) {
lbl.hidden = YES;
}
for (UILabel *lbl in _lbl_cancel) {
lbl.hidden = YES;
}
for (UILabel *lbl in _lbl_edit) {
lbl.hidden = NO;
}
这也是我得到以下异常并意识到我的 Button OUTletcollection 是空的。
-[UIButton countByEnumeratingWithState:objects:count:]:无法识别的选择器发送到实例 0xa8a8850
我既不覆盖 outletcollection,也不更改按钮的属性。 只是标签在集合中,而按钮不在。我也不知道为什么。
提前感谢您的帮助。
马夫
【问题讨论】:
标签: ios xcode ipad uibutton iboutletcollection