Handling gesture recognizers in iOS6

前端 未结 3 744
春和景丽
春和景丽 2021-02-07 13:19

Apparently iOS 6 tries to automatically handle the situation when you have a gesture recognizer and a UIButton in the same place, being activated for the same gestu

3条回答
  •  别跟我提以往
    2021-02-07 13:42

    I've done this to workaround the issue, change it as you see fit:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
          [self MyCommonSelector];// this will work for ios 5
          return Yes;
     }
    

    Add target in button where you declare so this will call in iOS 6:

    [self.myButton addTarget:self action:@selector(MyCommonSelector)
      forControlEvents:UIControlEventTouchUpInside];
    

    Do your stuff in this method which will also be called on button tap and from the gesture you need to call:

    -(void)MyCommonSelector
     {
        //Do your stuff here what you want to do with Gesture too.
     }
    

提交回复
热议问题