Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController page controls too close to home bar on iPhone X iOS 11

Tags:

ios

iphone-x

I have a program with one main view controller, which includes a button that the user can tap to display 4 pages of "Quick Help" via a UIPageViewController. The 4 pages are QuickHelpViewController0ID - QuickHelpViewController3ID, and each is a standard UIViewController. When they tap the button, I run this:

-(void)showQuickHelp
{
    // Load the quick help page view controller
    self.quickHelpPageVC = [self.storyboard instantiateViewControllerWithIdentifier:@"QuickHelpPageViewControllerID"];
    self.quickHelpPageVC.dataSource = self;

    // Create initial quick help page
    UIViewController *quickHelpVCA = [self quickHelpVCForPageIndex:0];
    NSArray <UIViewController *> *quickHelpVCs = @[quickHelpVCA];

    // And assign it to the page VC
    [self.quickHelpPageVC setViewControllers:quickHelpVCs direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

    [self presentViewController:_quickHelpPageVC animated:YES completion:nil];
}  // showQuickHelp:

I also provide a UIPageViewControllerDataSource to create each of the 4 pages as needed when the user scrolls to the next/previous page.

This works fine on iOS 9.3 and 10.x. It also works on 11.0 for all devices except the iPhone X (simulator). On that, the row of 4 page indicator dots is way down at the bottom of the screen, only 1 or 2 pixels above the new "home bar" that iOS 11 provides (slide up to switch apps, etc).

I found a video from Apple called Building Apps for iPhone X where the developer discusses fixing a similar problem, but in that case his solution was to simply change auto-layout to constrain a child UIPageControl to the bottom "safe area" instead of the traditional bottom layout guide. But I'm not using a UIPageControl on another view controller; I'm using a UIPageViewController, and I don't see any way to control the location of the page controls along the bottom of the window. (Yes, I've enabled the "Use Safe Area Layout Guides" option in Interface Builder.)

I can't imagine that iOS 11 sizes the UIPageViewController incorrectly by default in my scenario, nor do I see any obvious way to fix it. Any suggestions?

like image 749
Kenster999 Avatar asked Sep 27 '17 04:09

Kenster999


2 Answers

The fix for this is coming in 11.2

https://9to5mac.com/2017/10/30/ios-11-2-beta-1/

UIKit - Resolved Issues

Displaying a page control in UIPageViewController on an iPhone X no longer overlaps the home indicator at the bottom of the screen. (34478195)

like image 191
jlichti Avatar answered Sep 21 '22 21:09

jlichti


I had the same issue, but found that if I uncheck the 'Extend Edges - Under Bottom Bars' on the main view controller, the dots move up and appear correctly for iPhone X on the simulator. Unfortunately it also moves the dots up on all other devices... might not be an issue if there isn't too much on the page, but for me it truncated one page with lots of text on it.

It definitely looks like a bug, so I'll wait for Apple to hopefully fix the issue, as I'd rather not put nasty hacks to programmatically change the extend edges under bottom bars flag just for iPhone X

like image 38
cooman Avatar answered Sep 23 '22 21:09

cooman