UICollectionView tvOS Item not highlighting

I have a UICollectionView with a custom cell that contains an image and a line of text. When running in the simulator, no cells highlight showing that I want to select that item.


I'd like the highlighting to behave similar to selecting items on the 3rd Generation AppleTV, or how they're supposed to be selected on the new Apple TV.


I've implemented the suggested delegate methods. Selections seem to work well on a UITableView, but not on the UICollectionView.

Accepted Answer

Have you either checked off "Adjusts image when focused" for the UIImageView in your storyboard, or set the

adjustsImageWhenAncestorFocused
property to true for that UIImageView?

You don't get uicollectionviewcell selected for free. I got to change the background color of a highlighted cell with the following code:


- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context

withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {

context.nextFocusedView.layer.backgroundColor = [UIColor whiteColor].CGColor;

//GameCell is a subclass of UICollectionViewCell

if ([context.previouslyFocusedView isKindOfClass:[GameCell class]]) {

context.previouslyFocusedView.layer.backgroundColor = self.collectionView.backgroundColor.CGColor;

}

}

OMG! That worked. I didn't find that in the documentation. Thank you!

Well, yes it works, doing so expands my UIImageView to the width of the cell regardless of the contraines and regardless of the constraints I put upon it in the storyboard. It becomes at 400x400 image. I think, I can't tell.


So do I need to resize my images or do I need to find another solution?

UICollectionView tvOS Item not highlighting
 
 
Q