Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable Control Center in iOS 7 programmatically and if not, what are alternatives?

I have developed an app that uses swipe gesture from bottom up. It was working perfectly in iOS 6, but now iOS 7 came out, and it works maybe 1 out of 25 times: i get iOS 7 Control Center almost every time. Obviously, Control Center can be disabled in the Settings, but that is up to the phone owner, and I cannot control that. So my question is, is there a way to disable Control Center for the time when my app is running (or more likely, is "active", as I would want Control Center back if the user is not actively using my app). If not, what are the alternatives? Is relocating/reworking that functionality is the only solution?

like image 249
mike.tihonchik Avatar asked Oct 10 '13 21:10

mike.tihonchik


People also ask

Can you disable Control Center iPhone?

You may not be able to disable Control Center on the Lock screen, but you can turn off access within apps. Launch the Settings app on your iPhone or iPad. Tap Control Center. Turn the Access Within Apps switch off.

How do I close Control Center?

Open Control Center To close Control Center, swipe down or press the Home button.


2 Answers

Actually there is an option. You cannot disable it. But you can prevent the accidental launch. 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.

You can disable the status bar using this delegate in IOS7:

- (BOOL) prefersStatusBarHidden {     return YES; }  

And this method in IOS6.1 and prior:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
like image 192
Harikrishnan Avatar answered Sep 22 '22 09:09

Harikrishnan


Starting with the iOS 11 SDK (compiled in Xcode 9) additionally to implementing prefersStatusBarHidden:

Objective-C:

- (BOOL) prefersStatusBarHidden {     return YES; }  

Swift 4+:

override var prefersStatusBarHidden: Bool { return true } 

you also need to implement preferredScreenEdgesDeferringSystemGestures:

Objective-C:

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures{     return UIRectEdgeAll; }; 

Swift 4+:

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

Otherwise the Control/Notification Center appear directly; instead of first showing the gray box with a up/down arrow that needs to be dragged up/down.

like image 30
JeanLuc Avatar answered Sep 19 '22 09:09

JeanLuc