Use tvOS 13 UITabBarController compiled with Xcode 11 - tabBarObservedScrollView to scroll with content
Asked Answered
Q

1

9

My current project has a UITabBarController and in the UIViewController I have a ScrollView and inside that I have a Stack View.

The new default behaviour for the UITabBarController is to be pinned to the screen and allow the content to scroll underneath it.

But you are able to set an instance property to allow the tab bar to scroll away with the content as you navigate down.

I'm trying to set the instance property tabBarObservedScrollView in the viewWillAppear of the viewController as mentioned in the WWDC video at min 38 here: https://developer.apple.com/videos/play/wwdc2019/211/

But the problem I'm getting is that it doesn't scroll away. I've put a sample application together in GitHub so I can share it here to see if I'm doing something wrong.

If anyone has come across this issue already I'd be pleased to know how to fix it. Thanks :-)

https://github.com/kyazdani/TVTabBarScrollAway

Quintilla answered 27/9, 2019 at 9:32 Comment(0)
P
11

You need to set tabBarObservedScrollView on the actual view controller that is part of the array of view controllers that the UITabBarController handles.

In your example code you set it on the scroll view, but it's your UINavigationController that the UITabBarController manages, you need to set it there.

Painterly answered 24/10, 2019 at 22:4 Comment(2)
Thanks for this. I was previously setting this on the view controller like this: self.tabBarObservedScrollView = scrollView But after you description I should have been setting it like this: self.navigationController?.tabBarObservedScrollView = scrollView Thank you for your input. It's appreciated!Quintilla
Apple's docs do not make this clear, I was confused at first too.Painterly

© 2022 - 2024 — McMap. All rights reserved.