Colin Witkamp Colin Witkamp - 1 year ago 75
iOS Question

UIScrollView is not working properly when the parent view is used as a child ViewController of a TabBarController

I have an UIScrollView that is working properly in an UIViewController.


But,when I try to use the UIViewController as a child view controller of an UITabBarController, the screen is locked.
It seems that the

is not working.

contentSize is much smaller than before.

Answer Source

Using the TabBarController, setting the contentSize property in UIViewController's viewDidLoad override function worked.

    override func viewDidAppear(_ animated: Bool) {
        self.m_scrollView.contentSize = CGSize(width:UIScreen.main.bounds.width, height: m_height)

I tried to print the contentSize property in viewDidLoad and noticed that it was not changed as the value set in viewDidLayoutSubviews.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download