Hello,
I was wondering if anyone could give some tips on how to achieve this:
I have a tableview with a number of cells.
Each UITableCiewCell subclass has a UICollectionView with horizontal flowlayout (and scroll)
If the focus is on the 3rd cell of of the 1st UICollectionView (1st UITableCiewCell), swiping down to another UITableCiewCell should keep you at the same UICollectionView column. Instead the focus jumps to the first cell of the UICollectionView.
Are there any properties I can use to achieve the expected behavior?
Thank you in advance for your help!
Hello,
You should definitely be able to achieve what you want. Some questions to help me diagnose what the issue is:
- Are the table view cells, which contain the collection views, focusable themselves? Or have you configured them to not be focusable? (It's possible that, depending on how you have if configured, swiping down is actually focusing the table view cell first, which is then redirecting focus to the collection views inside. If so, we'll need to change this.)
- Are the collection view's configured to have `remembersLastFocusedIndexPath` set to `YES/true`? We'll want this set to `NO/false`, which is the default, to ensure that focus moves geometrically.
A helpful technique for seeing what the focus engine is thinking during a focus update is to look at `UIFocusUpdateContext` Quick Look images. To see this, set a breakpoint in a `-didUpdateFocusInContext:withAnimationCoordinator:` method for the table view, or a view or view controller that contains the table view. Now run your app and swipe down to move between table view rows, which should trigger the breakpoint. In Xcode's debugger, find the variable representing the `context` (of type `UIFocusUpdateContext`) that is passed in as an argument to that method. Now select it, and click the Quick Look icon or press the space bar to activate Quick Look. This should show an image of the focus update from the perspective of the focus engine. If you are able, reply to this thread with that image attached and I can explain what's going on.