NSCollectionView 不显示其内容
我想要做的是在我的应用程序中创建一个简单的 NSCollectionView 并用图像填充它。
我已经设法在界面生成器中设计/链接所有内容,并且尝试将任何内容的数组加载到集合视图中,以便它将在界面生成器中显示链接到它的视图(nib 文件),但我没有运气,所以远的。我无法让集合视图显示任何内容。
NSMutableArray * array = [[NSMutableArray alloc] init];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[myCollectionView setContent:array];
我遵循了在 Google 上找到的 2 个指南,但它们似乎已被弃用,它们在 Xcode 4 中不起作用
。我很绝望,请帮助我。我只想让 NSCollectionView 显示任何内容。我正在运行 Lion 和 xcode 4.1
What I want to do is create a simple NSCollectionView in my application and populate it with images.
I have managed to design/link everything in Interface Builder and I try to load an array of whatever into the collection view so that it will display the view (nib-file) linked to it in the interface builder, but I had no luck so far. There is no way I can make to collection view display anything.
NSMutableArray * array = [[NSMutableArray alloc] init];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[array addObject:@"Test"];
[myCollectionView setContent:array];
I have followed 2 guides I found on Google but they seem to be deprecated, they wont work in Xcode 4.
I'm desperate please help me. I just want to make the NSCollectionView to display anything. I'm running Lion and xcode 4.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题。
为了让 NSCollectionView 显示任何内容,您提供给它的 NSArray 必须将
nil
作为最后一个元素。之后 NSCollectionView 就显示得很漂亮了。
I solved the problem.
In order for the NSCollectionView to show anything, the NSArray that you provide to it must have
nil
as the last element.After that the NSCollectionView was displaying beautifully.