How to get iPhone X home bar to double swipe in landscape?

1k Views Asked by At

Landscape apps made with Xcode 8.3 are letterboxed on the iPhone X, and the home bar is partially disabled, meaning that the user must swipe up to "wake it" then swipe up again to exit the app. It's this second functionality that I want to implement while taking full advantage of the screen size, so how do I replicate that feature using Xcode 9?

If I set the view controller's prefersHomeIndicatorAutoHidden() to return true, the home bar temporarily disappears, but every time the user touches the screen it comes back (a bit jarring), but it still only takes a single swipe to exit the app. I have not been able to find any other options to do what I want, but clearly it should be possible since it automatically happens for older apps.

Suggestions?

[Note crossposted on Apple Developer Forum]

1

There are 1 best solutions below

1
On

This behavior is set up by implementing preferredScreenEdgesDeferringSystemGestures in a UIViewController, as follows:

- (UIRectEdge)
preferredScreenEdgesDeferringSystemGestures
{
    // prevent home bar from interfering
    return (UIRectEdgeTop | UIRectEdgeBottom);
}

Once this is done, the Home Bar should not be auto-hidden:

- (BOOL)
prefersHomeIndicatorAutoHidden
{
    return NO;
}

In addition, in a convenient place (such as viewDidAppear:), you need to notify the system that these properties have changed:

- (void)
viewDidAppear:(BOOL) isAnimated
{
    [super viewDidAppear:isAnimated];
    if (@available(iOS 11.0, *))
    {
        [self setNeedsUpdateOfHomeIndicatorAutoHidden];
        [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
    }
}