Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController: Child Controller ignoring status bar height during scrolling

I'm having some trouble with a UIPageViewController. If I scroll to a new page, the new view controller is behind the status bar while I'm scrolling. After the scrolling, the view controller position itself below the status bar.

I'm using Storyboard (Universal). UIPageViewController has attribute Extend Edges: Under Top Bars. What am I missing?

enter image description here

  • set automaticallyAdjustsScrollViewInsets to false didn't work
  • use of edgesForExtendedLayout = UIRectEdge.None didn't work either
  • found some open questions here but no answers ( link )

UPDATE

Another reason for the jumping are 'Margins' from 'Constraints' (found here). Ensure that you uncheck margins if you use constraints (right Dialog). You can remove them later in the Utilities (left Dialog). Check both of the connected views!

enter image description here

like image 382
longi Avatar asked Oct 22 '14 15:10

longi


People also ask

How do I navigate from page to page in uipageviewcontroller?

When navigating from page to page, the page view controller uses the transition that you specify to animate the change. In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages.

What is the uipageviewcontrollerdatasource protocol?

The UIPageViewControllerDataSource protocol is adopted by an object that provides view controllers to the page view controller on an as-needed basis, in response to navigation gestures. var delegate: UIPageViewControllerDelegate?

What is the uipageviewcontroller in tvOS?

In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages. Unlike in iOS, a user cannot interact with or move focus between items on each page.

How do I set the view controllers of a view?

When providing content view controllers one at a time, you use the setViewControllers (_:direction:animated:completion:) method to set the current content view controllers. To support gesture-based navigation, you must provide your view controllers using a data source object.


1 Answers

I just found a possible solution:

In my case, the UIPageViewController container had a Top Space of 0 constraint to its superview. The superview was the root container which contains the status bar.

I changed the value of the Top Space to 20, which is higher than the status bar. Now it doesn’t move the views below the status bar, because they already are.

Hope that helps!

like image 185
benjamin.ludwig Avatar answered Oct 22 '22 05:10

benjamin.ludwig