Focus From TabBar to CollectionView

I have a simple UITabBarController with a collection view in one of the controllers. When I move down, instead of the first item in the collection view getting focused, the 2nd item (which is closer to the selected tab bar item) becomes focused. I'm simply trying to get the first item focused when the user starts scrolling down. I would think that indexPathForPreferredFocusedViewInCollectionView would be called and I can set it there, but it doesn't happen. Do I need to look into adding a UIFocusGuide above my collection view, or is there a simpler solution?

Replies

UICollectionView actually already has a focus guide around it. Are your cells obscured by the tab bar at all? When your on the selected tab bar item what happens when you press Select?

I have exactly the same problem mentioned above, though its between 2 collection views one above the other (instead of a tab bar above the collection view).


- (NSIndexPath *)indexPathForPreferredFocusedViewInCollectionView:(UICollectionView *)collectionView { } does not get called.


I have set collectionView.remembersLastFocusedIndexPath = NO;


Interestingly if I set collectionView.remembersLastFocusedIndexPath = YES; the above mentioned method gets called the FIRST TIME ONLY (when there is no remembered index i guess), but for subsequent focus moves it remembers the index path an focuses directly.


Would appreciate some help with this.

Meanwhile... Years later. I have this exact problem. And I read what MWHUSS wrote -- "When your on the selected tab bar item what happens when you press Select?" and sure enough, I tried it, the behavior is different.


When I swipe down from the tabBar into the viewController, the collection view sets the focus to the middle cell - but when I Select the tabBar item instead of swiping down, the view controller still gets focus, but this time the first cell is focused, as desired.


In both cases, indexPathForPreferredFocusedViewInCollectionView is NOT called. If it were, it would return the indexPath for the first cell, but its never called.

How do I get the swipe down to do the same as the Select? Is anybody out there still?

Thanks in advance

J.