简体   繁体   中英

Disabling Dock in iOS programmatically

Is it possible to disable the dock that pops up in iOS?

This is my View Controller. Notice that it has a draggable view controller in the footer.

视图控制器的屏幕截图

But when I try to pull it up quickly, the dock shows up:

Dock出现的截图

Is there any way to disable it?

I think the closest you can get is iOS 11's preferredScreenEdgesDeferringSystemGestures() , which will show an indicator at the bottom but not pull up the dock on the first swipe. For example, in your view controller:

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
    return [.bottom]
}

In my experience it still eats the swipe gesture, but it still gives the user a second chance to hit the right target.

On iOS <11 however, this behavior can only be obtained by hiding the status bar.

Edit: Usually when faced with implementing a design choice like this, I try to offer a second, non-interfering gesture as a backup, such as a tap in that area, that has the same effect.

Normally such conflicts should be avoided, as they degrade user experience: how do you know that the user does not actually want to use the dock?

But if you really want, you can override the preferredScreenEdgesDeferringSystemGestures() method in the root controller to specify which edges should NOT (immediately) trigger system gestures.

eg

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
    return .bottom
}

As in iOS 11, you cannot disable the dock in an application, nor in Settings. I'd suggest providing a larger area for swiping up from the bottom.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM