代码之家  ›  专栏  ›  技术社区  ›  tobygriffin

IKImageBrowserView似乎绑定不正确

  •  0
  • tobygriffin  · 技术社区  · 14 年前

    我的问题涉及到接口生成器和IKImageBrowserView,它没有像我期望的那样实现绑定。

    这是我要将NSTextField的显示模式绑定到的关键路径: currentOrder.imagesArray.unvalidatedImages.arrangedObjects.@count

    当我尝试将以下键路径绑定到IKImageBrowserView的 content : currentOrder.imagesArray.unvalidatedImages.arrangedObjects 对于AppDelegate,Interface Builder没有给出任何错误,而是像我没有输入任何内容一样。当我单击返回到检查器时,绑定键路径再次为空。

    但是,它会将以下内容记录到控制台: 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.

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

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

    谢谢您!

    1 回复  |  直到 14 年前
        1
  •  1
  •   Dov    14 年前

    你试过实现 <IKImageBrowserDataSource> 在应用程序代理中,并使用 _dataSource Apple tutorial 是你做的。

    你基本上只需要实现 – numberOfItemsInImageBrowser: – imageBrowser:itemAtIndex: 提供数据,还不错。稍微棘手的部分是实现 <IKImageBrowserItem> 类来包装数据,但即使这样也不需要大量的工作。上面链接的教程应该会有很大帮助。