Ios 从UIButtons的IBMoutletCollection检索标记
我有一个iBootlet收藏的UIButtons。在我的可变按钮数组中,检索任何索引的标记最有效的方法是什么Ios 从UIButtons的IBMoutletCollection检索标记,ios,uibutton,nsmutablearray,iboutletcollection,Ios,Uibutton,Nsmutablearray,Iboutletcollection,我有一个iBootlet收藏的UIButtons。在我的可变按钮数组中,检索任何索引的标记最有效的方法是什么 @property(retain) IBOutletCollection(UIButton) NSMutableArray *emptySpaces; 这就是我的按钮的声明方式 @property (strong, nonatomic) IBOutlet UIButton *position1; 我试过以下方法。我做错了什么?多谢各位 if(emptySpaces[0].tag ==
@property(retain) IBOutletCollection(UIButton) NSMutableArray *emptySpaces;
这就是我的按钮的声明方式
@property (strong, nonatomic) IBOutlet UIButton *position1;
我试过以下方法。我做错了什么?多谢各位
if(emptySpaces[0].tag == 1){
}
或
要回答您的初始问题,NSMutableArray
-objectAtIndex:
返回的id
没有名为标记的接收器。在发送标记消息之前,应首先将结果强制转换为ui按钮
。如下所示:((UIButton*)self.emptyspace[0]).tag
您可以尝试以下方法:
for (UIButton *button in self.emptySpaces) {
if (button.tag == 1) {
}
}
你到底想达到什么目的?
for (UIButton *button in self.emptySpaces) {
if (button.tag == 1) {
}
}