ios - Xcode4 Interface Builder 中的引用 socket 集合是什么?

标签 ios iphone xcode4 interface-builder iboutletcollection

enter image description here

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

我要求 XCode4 的 InterfaceBuilder 中的“REFERENCING OUTLET COLLECTION 的新功能”。

最佳答案

IBOutletCollection 是一种对IBOutlets 进行分组的方法。假设您有 3 或 4 个 UILabels,您将在其上应用样式(字体、背景颜色、不透明度等)。使用 IBOutletCollection,执行此操作变得微不足道。首先,您需要定义您的 IBOutletCollection:

@property (nonatomic, retain) IBOutletCollection(UILabel) NSArray *labelsCollection;

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

在 Interface Builder 上连接 IBoutlets,然后迭代它:

for(UILabel *label in labelsCollection)
{
    // Apply your styles
}

希望这可以帮助您理解:

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

关于ios - Xcode4 Interface Builder 中的引用 socket 集合是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6649391/

相关文章:

objective-c - 代码 4 : How do you add an existing framework?

ios - 无法识别的选择器导致的 NSInvalidArgumentFormatException 已发送至发件人 : while trying to print tag of a UILabel

javascript - 事件 touchstart 在 iPhone 上不起作用

iphone - 隐藏/显示 UITableViewCell 附件公开指示器

ios - Xcode 4 - 一键构建到多个设备?

iphone - 如何从 "partial curl"类型segue返回

ios - [__NSCFArray insertObject :atIndex:]: mutating method sent to immutable object'

ios - NSData 对象因未知原因为空(保存图像)

iphone - Restkit内存不足警告

c++ - iOS - C/C++ - 加速积分图像计算