IKImageBrowserView 似乎未正确绑定

发布于 2024-09-10 10:07:24 字数 1271 浏览 3 评论 0原文

我的问题涉及 Interface Builder 和 IKImageBrowserView 未按照我的预期实现绑定。

我有一个相当长的关键路径来到达 NSArrayController,我想在 IKImageBrowserView 中显示其内容。

这是我将 NSTextField 的显示模式绑定到的关键路径: AppDelegate 的 currentOrder.imagesArray.unvalidatedImages.arrangedObjects.@count。 这工作正常,并为我提供了属于当前订单的图像数组中未经验证的项目的数量,这正是它应该做的。

当我尝试将以下关键路径绑定到 AppDelegate 的 IKImageBrowserView 的 contentcurrentOrder.imagesArray.unvalidatedImages.arrangedObjects 时,Interface Builder 没有给出错误,而是表现得好像我没有输入任何内容。当我单击返回检查器时,绑定键路径再次变为空白。

但是,它确实将以下内容记录到控制台: 忽略与使用绑定相关的异常:NSUnknownKeyException,[addObserver:forKeyPath:@"currentOrder.imagesArray.unvalidatedImages.arrangedObjects" ...] 被发送到“currentOrder”属性不符合 KVC 标准的对象。

我的 AppDelegate 将 currentOrder 实现为保留@property,所​​有子键也是@properties。我可以确定这些属性是 KVC 可以的,因为上面的 NSTextField 能够毫无问题地读取更改。有趣的是,IKImageBrowserView 的 selectionIndexes 能够绑定到 ...unvalidatedImages.selectionIndexes,只有 content 不能。

我已经实现了一种解决方法,在我的 nib 文件中放置一个 NSArrayController 并将内容数组绑定到 ...arrangedObjects 然后将 IKImageBrowserView 绑定到数组控制器,但我很高兴有一个更简洁的解决方案,或者至少知道我是否做错了什么。

谢谢你!

my question relates to Interface Builder and an IKImageBrowserView not implementing bindings as I would expect.

I have a fairly long key path to get to an NSArrayController, the contents of which I want to display in the IKImageBrowserView.

This is the key path I am binding an NSTextField's Display Pattern binding to:
currentOrder.imagesArray.unvalidatedImages.arrangedObjects.@count of the AppDelegate.
This works fine and gives me the number of unvalidated items in the array of images belonging to the current order, which is what it is supposed to.

When I attempt to bind the following key path to the IKImageBrowserView's content: currentOrder.imagesArray.unvalidatedImages.arrangedObjects of the AppDelegate, Interface Builder gives no error but instead acts as if I hadn't entered anything. When I click back to the inspector, the bindings key path is blank again.

It does however log the following to the Console:
Ignoring exception related to working with bindings: NSUnknownKeyException, [<NSCustomObject> addObserver:<IKImageBrowserView ...> forKeyPath:@"currentOrder.imagesArray.unvalidatedImages.arrangedObjects" ...] was sent to an object that is not KVC-compliant for the "currentOrder" property.

My AppDelegate implements currentOrder as an @property retained and all sub-keys are also @properties. I can be sure that these properties are KVC-okay because the NSTextField above is able to read changes without a problem. Interestingly enough the IKImageBrowserView's selectionIndexes is able to bind to ...unvalidatedImages.selectionIndexes, it's only the content that can't.

I have implemented a workaround whereby I have placed an NSArrayController in my nib file and bound the Content Array to ...arrangedObjects then bound the IKImageBrowserView to the array controller but would be very happy to have a neater solution, or at least to know whether I am doing anything wrong.

Thank you!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀟灑尐姊 2024-09-17 10:07:24

您是否尝试在应用程序委托中实现 的方法,并使用 _dataSource 连接而不是绑定?这对我有用,就是 Apple 教程 让您做到这一点。

您基本上只需要实现 – numberOfItemsInImageBrowser:– imageBrowser:itemAtIndex: 即可提供数据,这还不错。稍微棘手的部分是实现一个 类来包装您的数据,但即使这样也不需要付出巨大的努力。上面链接的教程应该会有很大帮助。

Did you try implementing the methods of <IKImageBrowserDataSource> in your app delegate, and using the _dataSource connection instead of a binding? That works for me, and is how the Apple tutorial has you do it.

You basically only need to implement – numberOfItemsInImageBrowser: and – imageBrowser:itemAtIndex: to provide the data, which isn't too bad. The slightly trickier part is to implement an <IKImageBrowserItem> class to wrap your data, but even that doesn't require massive effort. The tutorial linked above should help a lot.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文