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.
精彩评论