IBOutletCollection 和不同“种类”的多个对象没有按预期工作。谁知道为什么?

发布于 2024-12-27 03:10:09 字数 324 浏览 3 评论 0原文

我尝试使用插座集合作为 Segue 过滤的基础,而不是标识符,但是当我将对象添加到插座集合(一般使用 id 定义;见下文)时,我发现只有 UI 元素或其他非 ui 元素是实际上不是两者都添加到集合中。让我澄清一下,IB 似乎可以让您将对象添加到集合中。假设添加一个按钮和一个标签,然后添加一个手势识别器。这在 IB 中有效,不会出现错误或警告,但在运行时查询时,该集合仅包含 UI 类型元素。手势识别器无处可寻,但仅添加手势识别器,它将出现在集合中。有谁知道为什么?

@property(强,非原子)IBOutletCollection(id) NSArray *myCollection;

I'm trying to use an outlet colleciton as a basis for segue filtering instead of Identifier, but when I add objects to the outlet collection (defined generically using id; see below), I find only UI elements OR other non-ui elements are actually added to the collection not both. Let me be clear, IB lets you seemingly add the objects to the collection. Say add a button and a label then a gesture recognizer. This works in IB without error or warning, but when queryed at runtime, the collection contains only the UI type elements. The gesture recognizer is nowhere to be found, but add only the gesture recognizer and it will be present in the collection. Does anyone know why?

@property (strong, nonatomic) IBOutletCollection(id) NSArray *myCollection;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文