开发者

Connect items to a (specific index in) an array from Interface Builder

开发者 https://www.devze.com 2023-01-29 13:42 出处:网络
This one ought to be a softball for the Objective-C pros out there: Is there a way to connect an interface builder object to an element of an NSArray in Objective-C?The connecting would normally be d

This one ought to be a softball for the Objective-C pros out there:

Is there a way to connect an interface builder object to an element of an NSArray in Objective-C? The connecting would normally be done with IBOutlet, as in:

@interface ViewController : UIViewController {
    IBOutlet UILabel *label1;
    IBOutlet UILabel *label2;
    IBOutlet UILabel *label3;
    //...
}

Can I put 开发者_C百科the labels in an NSArray and still attach them to objects in interface builder?


You should be able to use IBOutletCollection, which is essentially an array of IBOutlets. Use this property declaration:

@property (nonatomic, retain) IBOutletCollection(/*whatever object you want an array of e.g. UILabel*/) NSArray *seats;

You will be able to connect multiple objects of one type to this in Interface builder.

0

精彩评论

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