手势互斥

1.如果一个视图添加了好几个手势

//拖拽手势

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(playerPan:)];

[m_touchView addGestureRecognizer:pan];

//单击手势

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playertap:)];

 [m_touchView addGestureRecognizer:tap];

//手势互斥

[tap requireGestureRecognizerToFail:pan];

为了防止一个视图添加了多种手势产生冲突

2.在AppDelegate中添加 [[UIButton appearance] setExclusiveTouch:YES];

这个也是相当于手势互斥,一个界面上面只有一个控件接受点击事件

上面的做法是省事的做法,也可以单独设置某个button的点击互斥事件

 

posted on 2017-01-04 10:32  敏言慎行  阅读(182)  评论(0编辑  收藏  举报

导航