Colin Witkamp Colin Witkamp - 1 month ago 7
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.

Working

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

contentSize
is not working.

contentSize is much smaller than before.

Answer

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

    override func viewDidAppear(_ animated: Bool) {
        print(self.m_scrollView.contentSize);
        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.