Disabling pull down control/notification center on iOS - ios

I am overriding this on my view controller to disable pulling down notification screen in case user is swiping down near the top.
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {
return [.top]
}
This works fine when I do pull near the center from the top, but the moment I start pulling down from the top left or right corners, it pulls down the control or notification menu. How do I disable it?

Unfortunately it can't be disabled. The best you can do is change the behaviour for full screen apps:
Swiping down over the area previously occupied by the status bar will only show a little tab. Only swiping the tab will then show the notification center. This has been enough to prevent accidental activation for me so far.
statusBarHidden = YES

Related

Code or setting to hide or change color of gesture bar (also called app switcher) iOS 10+

I need to make the screen go completely black in my app, but I still see the new thin line at the bottom that replaced the physical button in iPhone Xr and Xs.
I have looked at settings and googled like crazy. I called apple tech support to get the name of the bar itself. They said either 'gesture bar' or 'app switcher bar'. Do you know the code or setting required to change it's color or make it invisible?
N/A
Hoping to black out entire screen, but the thin line bar at the bottom shows up (this is not the tab bar or navigation items, but rather the new bar the user swipes up in the newer phones.)
You can use this UIViewController API that hide "Home Indicator".
https://developer.apple.com/documentation/uikit/uiviewcontroller/2887510-prefershomeindicatorautohidden
Override the following method on the ViewController you want to hide the indicator.
override var prefersHomeIndicatorAutoHidden: Bool {
return true
}
prefersHomeIndicatorAutoHidden
https://developer.apple.com/documentation/uikit/uiviewcontroller/2887510-prefershomeindicatorautohidden
setNeedsUpdateOfHomeIndicatorAutoHidden()
https://developer.apple.com/documentation/uikit/uiviewcontroller/2887509-setneedsupdateofhomeindicatoraut
childForHomeIndicatorAutoHidden
https://developer.apple.com/documentation/uikit/uiviewcontroller/2887508-childforhomeindicatorautohidden

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:
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.
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.
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
}

Swift UITableViewTable Footer moving up with keyboard

I'm developing a "pitch 'n putt" score card app (it's going to change the world). Except I've been pulling my hair out over using the UITableViewFooter.
When I click the player name, the keyboard appears but this is pushing the Footer up with the keyboard ,The overall effect does not look very good.
I've attached some screen shots which hopefully explain it better.
Is there a way to disable this behaviour?
Step 1 - Click Name
Step 2 - Keyboard appears and score totals are moved up as well.
I've turned into one of those guys that posts a question and solves it.
Anyway, in case it helps anyone else here is what I did.
1 - Create a global variable of
var playerFooter: UIView?
2 - in my func tableview (... viewForFooterInSection...)
just before my return
playerFooter = containerView (whatever you are returning)
3 - Add a notification for Keyboard show/hide and in side call
playerFooter!.hidden = true (or false depending on the notification)
It works great! but I won't claim this is the most efficient way of doing it.
When the keyboard appears the section disappears, when the keyboard disappears the footer reappears.
Thank you.

Override Control Center screen edge pan from bottom?

I’d like to use a UIScreenEdgePanGestureRecognizer on the bottom edge of my display. The recognizer works perfectly if I set its edges to UIRectEdgeLeft or UIRectEdgeRight, but UIRectEdgeTop or UIRectEdgeBottom do not work – they’ve overridden by some UISystemGestureGateGestureRecognizer.
I’m actually trying to override the Control Center in the same way that Facebook Paper has managed to do – figured the screen edge pan may have been their trick. Paper allows you to scroll from the bottom screen edge to pull their menu up, and Control Center doesn’t pop up at all. It’s definitely possible, I’m just wondering how they’ve done it.
Any thoughts?
There is a trick that lets you prevent the accidental launch of the Control Center. Just disable the status bar. Then on swipe the user will be prompted whether the control centre have to be launched or not.
It won't be launched in a single swipe. Instead an arrow appears on the first swipe and the user need to click and drag the arrow to launch the control centre, hence prevent accidental launch. Use this code to disable status bar.
I don't know if it will work in your case and your gesture recognizer will be fired but I would give it a try.
You can disable the status bar using this delegate method:
- (BOOL) prefersStatusBarHidden
{
return YES;
}
Hope it helps.
I don't know what I'm doing wrong but because the Facebook app hides the status bar they happen have the same behavior as in all full-screen apps in iOS.
I have tested it multiple times - the Control Center does not pop up, but the little tiny arrow to bring it up - does.
So your assumption is wrong - Facebook didn't disable Control Center, nor did they override any behaviors. The just hid the statusBar across the whole app.
Just set the key value View controller-based status bar appearance to NO in plist. Then hide it.
And it is the way to go.
And BTW, when you swipe the apps view down to reveal your profile and the status bar appears - try to swipe up from the very bottom edge of the screen. Believe me, you'll be totally amazed.
There's no magic here, no nothing. Facebook are big but they can't defy iOS rules. And I'd like it to be that way, honestly.
Here's the video of the process:
http://www.youtube.com/watch?v=A2CWvhxhGoY&feature=youtu.be
How about using UISwipeGestureRecognizer instead?

UISystemGateGestureRecognizer and delayed taps near bottom of screen

What are the standard UISystemGestureGateGestureRecognizers installed on the top level UIView of an iOS app for?
My app consists of two views - one fills the top half of the screen, the other is a custom keyboard and fills the bottom half. I found that taps on the space bar didn't always work and after some investigation found that the timing of tap events in the bottom 20 pixels or so was different to the rest of the view. For most of the view the period between touchesBegan/Ended was about 100ms, where as for the space bar it was 1-2ms. (My app is an emulator and this is too fast for it to detect the key press).
After some more digging I found the main UIView of the application (ie: my main view's superview) has 2 UISystemGestureGateGestureRecognizer's installed. By removing them in ViewDidAppear the bottom of the screen is no longer affected. (Presumably these are cancelling the touch press events to my keyboard hence the faster timing).
These system recognizers are present on at least iOS 5 through 7 and on both iPad and iPhone. I thought they may be related to swipe from top/bottom but this functionality still works with them removed.
So I have a fix, but I'd like to understand more about what's going on here - in particular what I might be breaking by removing these.
This delayed touches bothered me too.
Just as an addition to what's said before,
here's a simple fix:
override func viewDidAppear(_ animated: Bool) {
let window = view.window!
let gr0 = window.gestureRecognizers![0] as UIGestureRecognizer
let gr1 = window.gestureRecognizers![1] as UIGestureRecognizer
gr0.delaysTouchesBegan = false
gr1.delaysTouchesBegan = false
}
no need to remove those gesture recognizers.
just add this to the main view controller.
It appears that these recognizers are meant to prevent accidental touches near the top and bottom of the screen. They aren't configured with any targets, but can (like any UIResponder) absorb touches to prevent them from being passed up the responder chain.
Notes (tested on iOS 7.1):
Both gesture recognizers are always present in the key window.
I inspected both gestures' _targets ivar, and found they aren't configured with any targets at all. Swizzled out addTarget:action: to verify that targets weren't being added or removed on the fly.
delegate is always nil for both instances.
If you disable the gesture recognizers, they will re-enable themselves
The gesture that that doesn't delay content touches fires when you drag up from the bottom or drag down from the top. I couldn't trigger the instance that delays touches.

Resources