我有一个IBOutletCollection of UIButtons。在我的mutableArray of按钮中检索任何索引的最有效的方法是什么。
@property(retain) IBOutletCollection(UIButton) NSMutableArray *emptySpaces;我的按钮就是这样声明的
@property (strong, nonatomic) IBOutlet UIButton *position1;我试过以下几种方法。我做错什么了?谢谢
if(emptySpaces[0].tag == 1){
}或
if([emptySpaces objectAtIndex:0].tag == 1){
}发布于 2013-11-25 16:44:36
要回答您的初始问题,id是NSMutableArray -objectAtIndex:返回的内容,它没有一个名为tag的接收器。在发送标记消息之前,首先应该将结果强制转换为UIButton。像这样:((UIButton *)self.emptySpaces[0]).tag
你可以试试这样的方法:
for (UIButton *button in self.emptySpaces) {
if (button.tag == 1) {
}
}https://stackoverflow.com/questions/20198383
复制相似问题