I've some buttons outside my screen, I'd like to focus them
and I'd like to see them when they are focused.
I tried to put them in a UIScrollView, that does scroll
but sometimes it's not what I expected to get: I can't see my item at all!
Any idea?
I think I see the issue: the focus engine will scroll your scroll view to the maximum offset if you focus on the last item in the scroll view. This is intentional behavior, because without this it could sometimes be impossible to see the very top or very bottom of a scroll view.
Your best option is probably to choose a different content size for your scroll view: it should be large enough to contain your buttons, but not so large that scrolling to the bottom of it would put your buttons off-screen.
If you can't change the content size of your scroll view, you may instead want to use the UIScrollViewDelegate method to help the focus engine choose a better offset by implementing this method:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
The targetContentOffset parameter is a pointer to a CGPoint that is the content offset the focus engine is about to scroll your scroll view to. If you modify that point, then the focus engine will scroll there instead. You can use this to make sure it never scrolls too far past your buttons.