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;
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.
@IBAction is similar to @IBOutlet , but goes the other way: @IBOutlet is a way of connecting code to storyboard layouts, and @IBAction is a way of making storyboard layouts trigger code. This method takes one parameter, called sender . It's of type UIButton because we know that's what will be calling the method.
An IBOutlet helps connect the object control to the code to make the object accessible via the program. IBOutlet makes the connection between the declared instance variables wit the elements in the prototype cell. It typically holds these other objects as properties backed by instance variables.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With