gpt4 book ai didi

ios - 从 UIButtons 的 IBOutletCollection 中检索标签

转载 作者:行者123 更新时间:2023-11-29 03:28:03 26 4
gpt4 key购买 nike

我有一个 UIButton 的 IBOutletCollection。在我的 mutableArray 按钮中检索任何索引的标签的最有效方法是什么。

@property(retain) IBOutletCollection(UIButton) NSMutableArray *emptySpaces;

我的按钮是这样声明的

@property (strong, nonatomic) IBOutlet UIButton *position1;

我尝试了以下方法。我做错了什么?谢谢

if(emptySpaces[0].tag == 1){

}

或者

 if([emptySpaces objectAtIndex:0].tag == 1){

}

最佳答案

为了回答您最初的问题, NSMutableArray -objectAtIndex: 返回的 id 没有名为 tag 的接收器。在发送标签消息之前,您应该首先将结果转换为 UIButton。像这样: ((UIButton *)self.emptySpaces[0]).tag

你可以尝试这样的事情:

for (UIButton *button in self.emptySpaces) {
if (button.tag == 1) {

}
}

关于ios - 从 UIButtons 的 IBOutletCollection 中检索标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20198383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com