开发者

One IBOutlet for two UILabels

开发者 https://www.devze.com 2022-12-25 01:21 出处:网络
I have two views within one .xib (one view for landscape, another for portrait). How开发者_StackOverflow中文版 can I use the same IBOutlet I\'ve defined in @interface section for both labels if they h

I have two views within one .xib (one view for landscape, another for portrait). How开发者_StackOverflow中文版 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).


You can't. IBOutlet is an (UILabel?) object that must store reference to UI element. Naturally single object cannot reference to two different objects.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号