I successfully executed NSCollectionView 10.11 on my Mac application. It displays 10 items that I want, but I want the first item to be automatically selected when the application starts.
I tried the following in viewDidLoad and, alternatively, in the viewDidAppear functions;
let indexPath = NSIndexPath(forItem: 0, inSection: 0)
var set = Set<NSIndexPath>()
set.insert(indexPath)
collectionView.animator().selectItemsAtIndexPaths(set, scrollPosition: NSCollectionViewScrollPosition.Top)
I tried line 4 above and without animator
I also tried the following instead of line 4
collectionView.animator().selectionIndexPaths = set
with and without animator ()
While both of them include an index path in the selected index routes, neither of them displays the selected item.
Any clues I'm wrong about?
source
share