I have two views within one .xib (one view for landscape, another for portrait). How can I use the same IBOutlet I've defined in @interface section for both labels if they have the same functionality. (ctrl+dragging to both of them does'n help-each time I drag to second, the first one loses its outlet).
Asked
Active
Viewed 1,357 times
2 Answers
0
You can't. IBOutlet is an (UILabel?) object that must store reference to UI element. Naturally single object cannot reference to two different objects.

Vladimir
- 170,431
- 36
- 387
- 313
-
Did anybody come up with a better answer for how to do this, I'm having the same issue with outlets. – Alan Moore May 15 '12 at 22:44
-
@AlanMoore, you can use IBOutletCollection that can store a bunch of UI objects of the same class – Vladimir May 16 '12 at 06:57
0
Yes, of-course you can do this using IBOutletCollection
instead of IBOutlet
.
IBOutletCollection(UILabel) NSArray *labels;
Use the array to access all labels at runtime.

Nirav Dangi
- 3,607
- 4
- 49
- 60