如何将多个 IBOutlet 添加到数组中
这个特定的主题总是让我想知道是否有更有效的方法来做到这一点...
如果我的视图控制器中有 24 个 IBOutlet,并且我想将它们添加到 viewDidLoad 中的数组中,以便稍后引用循环是否有更好的方法来添加到数组除了:
[myArray addObject: iboutlet0];
[myArray addObject: iboutlet1];
[myArray addObject: iboutlet2];
[myArray addObject: iboutlet3];
[myArray addObject: iboutlet4];
...
...
...
有没有办法在循环块中将 IBOutlet 添加到 myArray ?
This particular topic has always made me wonder is there a more efficient way to do it...
If I have for example 24 IBOutlets in my view controller and I want to add them to an array in viewDidLoad for easy referencing at at later point in a loop is there a better way to add to the array apart from:
[myArray addObject: iboutlet0];
[myArray addObject: iboutlet1];
[myArray addObject: iboutlet2];
[myArray addObject: iboutlet3];
[myArray addObject: iboutlet4];
...
...
...
is there a way to add the IBOutlets to the myArray in a loop block?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Interface Builder 中将它们添加到
IBOutletCollection
中。不知道如何或是否排序,因此如果这很重要,您可以设置每个出口的标签值并按其排序。You could add them in Interface Builder to an
IBOutletCollection
. Don't know how or if it is sorted so if that is important, you could set the tag value of each outlet and sort by that.