NSCollectionView另一个NSCollectionView内 [英] NSCollectionView inside another NSCollectionView

查看:168
本文介绍了NSCollectionView另一个NSCollectionView内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这两个类:

@interface Father : NSObject
{
     NSString* name;
     NSArray* listChildren;
}

@property (copy, readwrite) NSString* name;
@property (copy, readwrite) NSArray* listChildren;

@end

@interface Child : NSObject
{
     NSString* nameChild;
     NSImage* picture;
}

@property (copy, readwrite) NSString* nameChild;
@property (copy, readwrite) NSImage* picture;

@end

我试图做一个 NSCollectionView 充满父亲项目,并为每个父亲项的查看我将有一个名称标签,另一个 NSCollectionView 充满(父亲)重新presentedObject.listChildren 项目。

I'm trying to make a NSCollectionView filled with Father items, and for each father item's View i will have a name label, and another NSCollectionView filled with the (father) representedObject.listChildren items.

我已经成功地创建了父亲的外部护理文件的查看来使事情更容易 NSCollectionViewItem ,但我不能给孩子的CollectionView 重新绑定presentedObject.listChildren 属性。其实,有在IB结合没有问题的,在运行时系统实际上是调用的属性(我已经添加和 getListChildren 的实施和调用的NSLog以确保财产被调用)。看来,内部的CollectionView 的将不会加载中找到的物品我的的NSArray *财产?

I've managed to create an external NIB file for the father NSCollectionViewItem's View to make things easier, but I'm not able to bind the child CollectionView to the representedObject.listChildren property. Actually, there is no problem in binding in IB, and at runtime the system is actually calling the property (I've added and getListChildren implementation and a NSLog call to make sure the property is being called). It seems that the inner CollectionView's won't load the items found in my NSArray* property?

这是推动我疯了,大概是什么回事任何想法?
帮助请!

It is driving me crazy, any ideas about what is going on? Help please!!

推荐答案

我有完全相同的问题,我找到了解决办法!

I had the exact same problem and I found the solution!

我是一个完整的新手到目标C和Cocoa,所以我不完全理解的原因,这并不完全工作。也许别人可以启发我们。

I'm a complete novice to Objective C and Cocoa so I don't fully understand the reasons why this does not work exactly. Maybe somebody else can enlighten us.

在我第一次尝试,我只是在默认的 MainMenu.xib 所做的一切。你最终有两个 NSArrayController的这种方式。现在很明显,当你怀疑问题出在第二个 NSArrayController的的内部项目。它在某种程度上没有得到复制正确。提取每个的NSView 到自己的的.xib 解决了这个问题。

In my first try I simply did everything in the default MainMenu.xib. You end up with two NSArrayController this way. Now apparently, as you suspected, the issue lies with the second NSArrayController for the inner items. It somehow doesn't get "copied" correctly. Extracting each NSView into its own .xib solves this issue.

其实这<一个href=\"http://www.cocoabuilder.com/archive/cocoa/283883-attempt-to-nest-an-nscollectionview-fails.html\"相对让我在正确的方向开始=nofollow的>的讨论。我后来发现/了解,这已经是暗示在基本相同的想法@ user493638。

Actually this discussion got me started in the right direction. I later discovered/understood that this is the basically the same idea @user493638 already hinted at.

结合这方面的知识与教程这里,如何提取意见到自己的的.xib 解决了这个问题对我来说!

Combining this knowledge with the tutorial here, on how to extract the views into their own .xib solved the problem for me!

我又不懂目标C和Cocoa远远不够充分AP preciate这种行为的根本原因,谁知道这一切结合魔法罩下究竟是如何工作的?

Again I don't understand Objective C and Cocoa nearly enough to fully appreciate the underlying reasons for this behavior, who knows how exactly all this binding magic works under the hood...

这篇关于NSCollectionView另一个NSCollectionView内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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