什么是Xcode4 Interface Builder中的引用插座集合?

Sag*_*ari 35 iphone interface-builder ios xcode4 iboutletcollection

在此输入图像描述

在这里,我指出了Referencing Outlet Collection.我无法弄清楚它在XCode4中的用法.

我要求在XCode4的InterfaceBuilder中提供"REFERENCING OUTLET COLLECTION的新功能".

Rui*_*res 58

IBOutletCollection是一种分组的方式IBOutlets.想象一下,你有3或4 UILabels,你将在其上应用一种风格(字体,backgroundColour,不透明度等).使用a IBOutletCollection,这样做变得微不足道.首先,您需要定义IBOutletCollection:

@property (nonatomic, retain) IBOutletCollection(UILabel) NSArray *labelsCollection;
Run Code Online (Sandbox Code Playgroud)

(注意我们放在括号内的类型,虽然我们可以放一个id,如果我们有一个混合集合)

连接IBoutletson Interface Builder,然后迭代它:

for(UILabel *label in labelsCollection)
{
    // Apply your styles
}
Run Code Online (Sandbox Code Playgroud)

希望这有助于您理解:

http://useyourloaf.com/blog/2011/3/28/interface-builder-outlet-collections.html