首页 文章

在NSCollectionView示例中拖放

提问于
浏览
4

我需要在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;
}

代表已设置 .

有人知道解决方案吗?

3 回答

  • 0

    您需要做两件事:确保在NSCollectionView中打开您的选择并实施

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

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

  • 3

    它已经在工作了 .

    你必须点击,等待一秒钟 . 秒之后 . 点击它被拖动...

    -.-

  • 4

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

相关问题