prefersHomeIndicatorAutoHidden not working on iPhone X

守給你的承諾、 提交于 2019-12-05 07:09:23

If you show your UIViewController in UINavigationController, you have to override childViewControllerForHomeIndicatorAutoHidden() function:

extension UINavigationController {
    open override func childViewControllerForHomeIndicatorAutoHidden() -> UIViewController? {
        return topViewController
    }
}

Or if you show your UIViewController like subview of parent view controller, you also have to override this function and return child view controller.

As per developer guide for prefersHomeIndicatorAutoHidden its clear that,

The system takes your preference into account, but returning YES is no guarantee that the indicator will be hidden.

This method is only helpful if any of the objects are overlapping with the home indicator.

FYI, the home indicator will hide only after a couple of seconds, but it will reappear as soon as the user touches the screen.

Swift version of @Beniamin's answer:

extension UINavigationController {
    open override var childForHomeIndicatorAutoHidden: UIViewController? {
        return topViewController
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!