UIGestureRecognizer和UIbutton事件
处理:
1、添加协议<UIGestureRecognizerdelegate>
2、接收协议。
UITapGestureRecognizeralloc *tapGest= [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapUserImageView:)];
//正常结束,重新触摸
tapGest.cancelsTouchesInView=NO;
//定义协议
tapGest.delegate=self;
////单指双击
//tap.numberOfTouchesRequired = 1;
//tap.numberOfTapsRequired = 2;
//定义tag
self.view.tag=i+10;
//添加手势
[self.view addGestureRecognizer:self.tapGest];
//判断按钮还是手势的协议代理
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch
{
//判断是不是UIButton的类
if([touch.viewisKindOfClass:[UIButtonclass]])
{
returnNO;
}
else
{
returnYES;
}
}
#pragma mark - action
-(void)DelContact:(UIButton*)sender
{
if([senderisKindOfClass:[UIButtonclass]])
{
//按钮事件;
}
}
//点击进入好友详情
- (void)tapUserImageView:(UITapGestureRecognizer*)tap
{
NSLog(@"11111111====%ld",tap.view.tag);
if([tapisKindOfClass:[UIGestureRecognizerclass]])
{
//手势事件;
}
}