3

我需要在 NSCollectionView 中拖放。

所以我查看了 Apples 代码示例: https ://developer.apple.com/library/mac/#samplecode/IconCollection/Introduction/Intro.html

有一种拖动的方法。但它不起作用。

我添加了以下没有结果的方法:

-(BOOL) collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event {
    return YES;
}

委托已设置。

有人知道解决方案吗?

4

3 回答 3

4

你需要做两件事:确保你的选择在你的 NSCollectionView 中打开,并实现

- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard

collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent *)event除非您想要可变的可拖动性,否则没有必要实现。如果您不实现它,集合视图将尝试为集合中的每个项目开始拖动。

于 2012-03-27T20:15:35.563 回答
3

它已经在工作了。

您必须单击,最多等待一秒钟。秒后。单击它被拖动...

-.-

于 2011-01-22T23:19:27.673 回答
0

您可以在集合项视图原型中实现拖放。NSView如果您在自己的子类中实现所需的方法,则每个都支持拖动。

于 2011-04-29T15:50:57.397 回答