Miras Maratuly
Miras Maratuly

Reputation: 246

UIPageViewController's frame of the view is unpredictable on iOS

I am trying to assign frames of UIPageController's child views. I have created a view on the storyboard, assigned a constraints, made an outlet. But in the application it acts weird.

    self.pageviewcontroller.view.frame = self.viewForPageContent.frame
    self.addChildViewController(pageviewcontroller)
    self.view.addSubview(pageviewcontroller.view)
    self.pageviewcontroller.didMove(toParentViewController: self)

red rectangle is viewForPageContent:

enter image description here

and results are the following, on my iphone 5s it gets incredibly weird:

enter image description here

///but on the 7 simulator it gives correctly placed view, but with dots. What could be the issue?

Upvotes: 2

Views: 474

Answers (1)

Miras Maratuly
Miras Maratuly

Reputation: 246

eventually I did not find the proper solution, but my workaround is the following peace of code, in case anyone else meets the problem:

self.pageviewcontroller.view.frame =
        CGRect(x: 0,
               y: UIApplication.shared.statusBarFrame.height
                + (self.navigationController?.navigationBar.frame.height)!
               width: self.view.frame.size.width,
               height: self.view.frame.size.height
                - (self.navigationController?.toolbar.frame.height)!
                - (self.tabBarController?.tabBar.frame.height)! )

Upvotes: 1

Related Questions