Cocoa - NSCollectionView和NSCollectionViewItem之间的链接在哪里? Xcode 6 Bug? [英] Cocoa - Where is the link between a NSCollectionView and a NSCollectionViewItem? Xcode 6 Bug?

查看:989
本文介绍了Cocoa - NSCollectionView和NSCollectionViewItem之间的链接在哪里? Xcode 6 Bug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将NSCollectionView拖动到视图时,NSCollectionViewItem会显示在故事板上,四处飘动。

When you drag a NSCollectionView to a view, a NSCollectionViewItem appears on the storyboard, floating around.

想象一下,我将几个NScollectionViews拖动到同一个视图。我将有一堆NSCollectionViewItems。集合视图如何知道哪个NScollectionViewItem属于它?在接口构建器上可以看到两者之间的连接?我没有看到任何东西在界面生成器?我在哪里可以看到?

Imagine I drag several NScollectionViews to the same view. I will have a bunch of NSCollectionViewItems. How a collection view knows which NScollectionViewItem belongs to it? Is there a connection between the two that can be seen on interface builder? I don't see anything on interface builder? Where to do I see that?

编辑:显然这似乎是一个Xcode错误。当你添加一个NSCollectionView到故事板,它没有一个链接到NSCollectionViewItem,它似乎是不可能的,它们之间连接itemPrototype插座。

Apparently this seems to be a Xcode bug. When you add a NSCollectionView to the storyboard, it comes without a link to the NSCollectionViewItem and it seems to be impossible to connect the itemPrototype outlet between them.

bug这样,他们的答案是:这是一个与OS X上的故事板的已知问题。使用Xibs代替。我的建议是:不要使用OS X的故事板。事情是半熟并且充满了bug。

After contacting Apple about bugs like this, their answer was: "this is a know issue with Storyboards on OS X. Use Xibs instead." My advice to you is: never use storyboards with OS X. The thing is half cooked and full of bugs.

编辑:今天,一年后,Xcode 7.1仍然存在这个错误。建议仍然有效。不要在你的OS X应用程序使用storyboards,直到苹果在未来10年修复这个问题...

today, one year later, the bug still exists on Xcode 7.1. The advice is still valid. Don't use storyboards with your OS X apps, until Apple fixes this in the next 10 years...

推荐答案

我给@ RubberDuck的解决方法去了,但它没有工作(参见我的评论)。对我有用的是在视图控制器(Xcode 6.1)的 viewDidLoad 中设置 collectionView.itemPrototype

Well, I gave @RubberDuck's workaround a go but it didn't work (see my comment). What worked for me is setting collectionView.itemPrototype in viewDidLoad of the view controller (Xcode 6.1):

@IBOutlet weak var collectionView: NSCollectionView!

override func viewDidLoad() {
    // don't forget to set identifier of CollectionViewItem 
    // from interface builder
    let itemPrototype = self.storyboard?.instantiateControllerWithIdentifier("collectionViewItem")
        as NSCollectionViewItem
    self.collectionView.itemPrototype = itemPrototype
}

这篇关于Cocoa - NSCollectionView和NSCollectionViewItem之间的链接在哪里? Xcode 6 Bug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆