How to make IBOutlets out of an array of objects?

后端 未结 5 1409
南旧
南旧 2020-12-30 20:13

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;

a

5条回答
  •  太阳男子
    2020-12-30 20:49

    It is possible, it’s called outlet collection. This is the way to define an outlet collection:

    @property(retain) IBOutletCollection(UIImageView) NSArray *images;
    

    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.

提交回复
热议问题