I am developing a tvOS app in swift. I am using UITabBarController
in the app.
My requirement is to hide the tabbar automatic after 10 seconds and focus can move to AVPlayerViewController
inside the tabbar item.
I tried to override preferredFocusedView
, but focus cannot move to AVPlayerViewController
.
func updateFocus() {
self.playerController.view.hidden = false
self.playerController.view.alpha = 1.0
self.playerController.view.userInteractionEnabled = true
self.playerController.view.layer.zPosition = 1.0
self.preferredFocusedView
setNeedsFocusUpdate()
updateFocusIfNeeded()
}
override var preferredFocusedView: UIView? {
return self.playerController.view
}
Please suggest me how to move focus programmatically.
Issue is
focus
is not inviewController
at that time instead focus is intabBarController
, so what I will suggest you is do something like this, Create aTabBarController
subClass and set class of your tabController in story board to that class, and then intabBarController
subClass do something like this.My selected view controller here is FirstViewController which look like this and its working fine.