I'm using a UICollectionViewController and I'm trying to set an item as selected automatically (ie. previously selected options). If I attempt to set when I'm setting the cells data
def collectionView(view, cellForItemAtIndexPath: index_path)
//create the cell etc.. then
cell.selected = true
cell.update(index_path.row)
end
I get NoMethodError for selected. However this works from the normal select/deselect methods.
def collectionView(view, didSelectItemAtIndexPath: index_path)
cell = view.cellForItemAtIndexPath(index_path)
cell.selected = true
end
Any ideas on how can I automatically preselect a cell?
Thanks,
To preselect a cell in a Collection View named
myColView
, call:This method does not cause any selection-related delegate methods to be called.