IBOutletCollection 未与 Storyboard 中的 UILabels 连接

IBOutletCollection not connected with UILabels in Storyboard

我有一个 IBoutletCollection 属性 连接到 Storyboard 中的几个 UILabels:

@property (weak, nonatomic) IBOutletCollection(UILabel) NSArray *labels;

NSLog(@"%ld",(long)self.labels.count)viewDidLoad

之后

得到 0 作为结果。

我这里的 ivar 是空的,这是怎么回事?

Autolayout有什么问题吗? (是的,我在 Storyboard 中使用它)

感谢任何建议!

weak更改为strong

@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *labels;