Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Dock in iOS programmatically

Tags:

xcode

ios

swift

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.

screenshot of the view controller

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

screenshot of the Dock appearing

Is there any way to disable it?

like image 355
iOS Developer Avatar asked Feb 26 '18 12:02

iOS Developer


3 Answers

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.

like image 78
Samantha Avatar answered Nov 12 '22 01:11

Samantha


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.

like image 2
Tamás Sengel Avatar answered Nov 12 '22 01:11

Tamás Sengel


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.

e.g.

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
    return .bottom
}
like image 2
Marcpek Avatar answered Nov 12 '22 01:11

Marcpek