I do not know why this does not work. indexOfIcon is correct, the section is correct (marked in NSLog) If I select one, everything will be correct. But this line does nothing ... why? If selected, it should have a blue frame. This works great by doing it "manually", but not with code.
- (void)viewWillAppear:(BOOL)animated
{
NSUInteger indexOfIcon;
if(self.mainCategory.icon){
indexOfIcon = [self.icons indexOfObject: self.mainCategory.icon];
} else {
indexOfIcon = 0;
}
[self.collectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:indexOfIcon inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionBottom];
}
source
share