我对MacOS开发非常陌生,但我是一个经验iOS开发人员。
我有一个NSCollectionView,我已经连接到一个NSCollectionViewFlowLayout上,用于水平滚动,我给它添加了很多单元格,它可以工作,好吧,它只适用于神奇的鼠标滑动滚动,它忽略了所有的鼠标命中事件,所以我不能用鼠标滚动它。我可以向单元格中添加一个按钮,这样就可以检测到单击操作。
我在iOS上遇到了类似的问题,iOS被设置为假的或者什么的。
有什么想法吗?
提前感谢

class ViewController: NSViewController {
@IBOutlet weak var slidesCollection: NSCollectionView!
var slide : [String] = ["one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two","one", "two"]
override func viewDidLoad() {
super.viewDidLoad()
let flowLayout = NSCollectionViewFlowLayout()
flowLayout.itemSize = CGSize(width: 100, height: 100)
flowLayout.scrollDirection = .horizontal
flowLayout.minimumInteritemSpacing = 10.0
flowLayout.sectionInset = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
slidesCollection.collectionViewLayout = flowLayout
slidesCollection.dataSource = self
let nib = NSNib(nibNamed: Cell.name, bundle: nil)!
slidesCollection.register(nib, forItemWithIdentifier: Cell.identifier())
}
}
extension ViewController: NSCollectionViewDataSource {
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
return slide.count
}
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = collectionView.makeItem(withIdentifier: Cell.identifier(), for: indexPath)
return item
}
}发布于 2021-02-12 16:28:49
好的,这似乎是正常的,我只是注意到其他的MacOS应用程序做了同样的魔术鼠标!想想会回到iOS开发,上一次我做桌面应用开发是近20年前的Windows。好了!
https://stackoverflow.com/questions/66172725
复制相似问题