UITapGestureRecognizer not working in UIImageView

前端 未结 9 1637
长发绾君心
长发绾君心 2021-01-03 18:16

I had the following code:

UITapGestureRecognizer *showStoryTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showNewsStory         


        
9条回答
  •  甜味超标
    2021-01-03 19:13

    if you allowed 2 different gesture, you should add below code snippet. For example, you use pickerView and also you want to detect tap gesture for same pickerView.

    Asks the delegate if two gesture recognizers should be allowed to recognize gestures simultaneously.

    Objective C

        -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
        return true;
    }
    

    Swift

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
    

提交回复
热议问题