NSCollectionView选择要在OS X中进行序列化的项目

问题描述 投票:0回答:1

我查看了NSCollectionView API,发现与我所见的某些教程匹配的任何内容。 Xcode强迫我这样编写我的方法,以便没有错误:

@objc(collectionView:didSelectItemsAtIndexPaths:) func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
    print("Selected")
}

[每当我在NSCollectionView中单击一个项目时,都不会发生任何事情,并且我的打印语句永远不会显示在控制台中。从NSCollectionView中选择项目的正确方法是什么?

swift macos swift3 nscollectionview nscollectionviewitem
1个回答
0
投票

您应该将属性isSelectAble = true设置为这样:

self.collectionView. isSelectAble = true
© www.soinside.com 2019 - 2024. All rights reserved.