UIView上添加了一个按钮和一个单击手势的事件相应,互相不影响的处理方法。。

tapGesture.delegate = self;



- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch



{



    CGPoint location = [touch locationInView:self.view];



    if(CGRectContainsPoint(button.frame, location))



    {



        return NO;



    }



    return YES;



}

响应如上委托方法,判断,手势的触击方法是否在按钮区域,如果是,则返回NO,禁用手势。否则返回YES

 

 

你可能感兴趣的:(UIView)