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

后端 未结 3 1035
攒了一身酷
攒了一身酷 2020-11-30 02:28

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

相关标签:
3条回答
  • 2020-11-30 02:55

    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];
    
    0 讨论(0)
  • 2020-11-30 03:04

    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.

    0 讨论(0)
  • 2020-11-30 03:14

    No alternatives, really. The best you can do is warn users and ask them to go to settings to turn it off.

    Realistically, you'll lose a lot of users just by asking that, so you should change the gestures.

    0 讨论(0)
提交回复
热议问题