如何从一个对象数组中制作IBOutlets? [英] How to make IBOutlets out of an array of objects?
问题描述
我想用Interface Builder中的一堆UIImageViews创建一个数组。而不是20或30
I want to make an array with a bunch of UIImageViews I have in Interface Builder. Instead of having 20 or 30
IBOutlet UIImageView *img1;
并将它们全部链接起来,然后将它们放入数组中,是否有办法声明一组IBOutlet UIImageViews?
and linking them all that way, and then putting them into an array, is there a way to declare an array of IBOutlet UIImageViews?
我的头文件中没有这么多声明。
Just so I don't have so many declarations in my header file.
推荐答案
有可能,它被称为 outlet collection 。这是定义outlet集合的方法:
It is possible, it’s called outlet collection. This is the way to define an outlet collection:
@property(retain) IBOutletCollection(UIImageView) NSArray *images;
现在您可以在Interface Builder中将多个对象粘贴到插座中,将创建该阵列在你加载界面时为你服务。
Now you can stick more than one object into the outlet in the Interface Builder, the array will be created for you when the interface is loaded.
这篇关于如何从一个对象数组中制作IBOutlets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!