UINavigationController interactivePopGestureRecognizer working abnormal in iOS7

前端 未结 3 1867
礼貌的吻别
礼貌的吻别 2020-12-08 08:39

In iOS7, we have a new \"swipe left to right\" gesture, this is a very useful feature, but now I have a problem with it.

I use this code to custom the back button in

相关标签:
3条回答
  • 2020-12-08 08:50

    Setting the interactivePopGestureRecognizer.delegate to self is only the first step. The second step is to implement

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
        return ![otherGestureRecognizer isKindOfClass:UIPanGestureRecognizer.class];
    }
    

    The test against the pan gesture recognizer is needed to block vertical scrolling of a scroll or table view while the interactive pop is in progress.

    0 讨论(0)
  • 2020-12-08 08:55

    This code can wroks well for me.

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }
    
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return [gestureRecognizer isKindOfClass:UIScreenEdgePanGestureRecognizer.class];
    }
    
    0 讨论(0)
  • 2020-12-08 09:11

    Add in Class Controller "UIGestureRecognizerDelegate"

    in ViewDidApper add

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
    
        self.navigationController?.interactivePopGestureRecognizer.delegate =  self
    }
    

    =)

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