iPhone-X - How to force user to swipe twice home indicator to go home-screen

前端 未结 4 1654
醉话见心
醉话见心 2021-02-05 17:55

I\'m using the code below to hide the home indicator on iPhone X, which is working fine in the emulator.

-(BOOL)prefersHomeIndicatorAutoHidden
{
    return YES;
         


        
4条回答
  •  面向向阳花
    2021-02-05 18:42

    It is a choice between hidden and deferred but NOT both

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

    register the gesture in 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 the handleGesture, no need to do anything there for this to work

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

    should be it

提交回复
热议问题