Dismiss modal form sheet view on outside tap iOS 8

前端 未结 3 1649
故里飘歌
故里飘歌 2020-12-14 08:08

I\'ve been trying to dismiss the modal form sheet view on outside tap on iOS 8 with no luck, I\'ve tried this code

UITapGestureRecognizer *recognizer = [[U         


        
3条回答
  •  被撕碎了的回忆
    2020-12-14 08:51

    In iOS 8, You can look at using the new UIPresentationController class. It gives you better control over the container around your custom view controller presentation (allowing you to correctly add a gesture recogniser of your own).

    Here is a link to quite a simple tutorial as well: http://dativestudios.com/blog/2014/06/29/presentation-controllers/

    Then add the dimming view tap-to-dismiss:

        UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
        [self.dimmingView addGestureRecognizer:singleFingerTap];
    
    
    - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
        [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    }
    

提交回复
热议问题