0

I have a rootviewcontroller which is extending UITabBarController. It has several children viewcontrollers.

All I want is to programmatically select the 2nd/3rd/.. viewcontroller from the first one. I've used

`.selectedViewController`, `.selectedIndex`, `.navigationController.tabBarController.tabBar.selectedItem = ...` 

and all the variations on this theme. I notice the following when using

`tabBarController.selectedViewController = tabBarController.viewControllers?[1]` 

The tabBarController displays the 2nd viewcontroller for a second but goes back to the 1st viewcontroller. I have a hunch this is the focus engine but I'm lost at this point.

Rich Benner
  • 7,873
  • 9
  • 33
  • 39
alina
  • 1

2 Answers2

4

Not completely sure if it's related but I had a tvOS app where I had several UIViewControllers in a UITabBarController and I stopped being able to select them in the tab bar and have the tab bar go away once I upgraded to tvOS 10.

Turns out the issue is that those screens did not have any focusable elements on them (buttons, etc.) so I had to make subclass objects for some of the views and make the canBecomeFocused property return "true".

see: How to make a UIView focusable using the focus engine on Apple TV

You have to implement a second thing to make them appear focused but if you don't actually want that you can skip it.

Community
  • 1
  • 1
Tom Kidd
  • 12,830
  • 19
  • 89
  • 128
0

I was setting an UITabBarItem for each controller.

alina
  • 1