【发布时间】:2015-06-07 01:31:45
【问题描述】:
我已尝试遵循本指南:
Quick Start for Collection Views
在集合视图项中使用 NSImageView。
如果我使用 Image Well 设置图像也不会显示任何内容,如果我通过代码设置数组也不会显示。
所以我尝试以编程方式使用
func representedObject(representedObject: AnyObject)
{
super.representedObject = representedObject
photoImageView.image = (representedObject as! NSImage)
println("\(representedObject)")
}
在集合视图项(子类)中。
如果我不继承 Collection View Item Xcode 告诉我没有原型集,如果我对它进行子类化它会告诉“无法加载 nibName”...(它在故事板中具有正确的身份集)
我无法使用此 Collection View :-(
无论如何,我喜欢绑定...所以我想通过绑定实现正确的结果.. 我检查并重新检查了链接中文档中的每个段落,一切似乎都很好。主要区别在于文档使用应用程序委托,我使用的是视图控制器。
我迅速翻译了 KVC 方法,我认为它们是正确的,因为我知道它们已被调用。他们是:
func insertObject(p: ClientPhoto, inClientPhotoArrayAtIndex index: Int) {
images.insertObject(p, atIndex: index)
}
func removeObjectFromClientPhotoArrayAtIndex(index: Int) {
images.removeObjectAtIndex(index)
}
func setClientPhotoArray(a: NSMutableArray) {
images = a
}
func clientPhotoArray() -> NSArray {
return images
}
【问题讨论】:
标签: cocoa cocoa-bindings nscollectionview kvc nscollectionviewitem