2010-12-09 69 views
0

这一个阵列应该是对于目标C利弊垒球那里:连接项到(在特定索引)从界面生成器

是否有一个界面生成器对象连接到元素的方式Objective-C中的NSArray的?通常会用IBOutlet完成的连接,如:

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

我可以把一个NSArray的标签,还是将它们连接到在界面生成器对象?

+0

我不认为这是可能的 – Vjy 2010-12-09 20:29:26

+1

试试这个答案:http://stackoverflow.com/questions/4268972/variable-iboutlet-name – Anna 2010-12-09 20:43:18

回答

4

您应该可以使用IBOutletCollection,它本质上是一个IBOutlets数组。 使用该属性声明:

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

你将能够把一个类型的多个对象连接到这个在Interface Builder。