iOS,手势和Button共存,button动作被屏蔽怎么办。

tapGestureRecognizer.cancelsTouchesInView = NO; 

 

 

在手势初始化的时候加上这句就行了。

 

或者用UIControl替换当前的self.view,代码如下:

    UIControl *control = [[UIControl alloc] initWithFrame:self.view.frame];
    [control addTarget:self action:@selector(controlTapped) forControlEvents:UIControlEventTouchUpInside];
    self.view = control;
    [control release];

 

猜你喜欢

转载自duchengjiu.iteye.com/blog/1950577