IPhone-X - How to get the user to double-scroll the home indicator to go to the main screen

I use the code below to hide the home indicator on the iPhone X, which works fine in the emulator.

-(BOOL)prefersHomeIndicatorAutoHidden
{
    return YES;
}

But even though it is hidden, I can still swipe up from the bottom, and my game goes to the home screen.

I saw several games in which the user has to swipe up once to bring up the home indicator, and again swipe up to go to the main screen.

So, how can I get the user to double-show the home indicator to go to the home screen in iOS 11 with Objective-C?

This behavior is required for full-screen games.

+6
source share
3 answers

ViewController :

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
    return UIRectEdgeBottom;
}

, , .

UIRectEdgeAll UIRectEdgeBottom, .

+5

.

PrefersHomeIndicatorAutoHidden NO, PreferredScreenEdgesDeferringSystemGestures UIRectEdgeBottom.

Swift 4.2

override var prefersHomeIndicatorAutoHidden: Bool {
  return false
}

override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {
  return UIRectEdge.bottom
}
+4

, ,

-(BOOL)prefersHomeIndicatorAutoHidden
{
    // YES for hidden (but swipe activated)
    // NO for deferred (app gets priority gesture notification)
    return NO;  
}

viewDidLoad

UIScreenEdgePanGestureRecognizer *sePanGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
sePanGesture.edges = UIRectEdgeAll; 
// or just set the bottom if you prefer, top-right seems to behave well by default
[self.view addGestureRecognizer:sePanGesture]; 

and define handleGesture, no need to do anything to make it work

- (void)handleGesture:(UIScreenEdgePanGestureRecognizer *)recognizer {
    // to get location where the first touch occurred from docs
    // CGPoint location = [recognizer locationInView:[recognizer.view superview]]; 

    NSLog(@"gestured");
}

it should be

+2
source

Source: https://habr.com/ru/post/1689440/


All Articles