OGeek|极客世界-中国程序员成长平台

标题: ios - IBOutletCollection 未与 Storyboard 中的 UILabel 连接 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:06
标题: ios - IBOutletCollection 未与 Storyboard 中的 UILabel 连接

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

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

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

之后

得到 0 作为结果。

我在这里得到空的 ivar 是什么问题?

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

感谢您的建议!



Best Answer-推荐答案


weak 改为 strong

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

关于ios - IBOutletCollection 未与 Storyboard 中的 UILabel 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32221139/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4