开发者

Detect anytouch inside subView (other than a button) touchesEnded

开发者 https://www.devze.com 2023-04-06 16:03 出处:网络
I have a subview, which also contains a UIButton. Now, once I enter the touchesEnded, I want to exec开发者_JAVA技巧ute some instructions only if the main subview was touched (and not the UIButton).

I have a subview, which also contains a UIButton. Now, once I enter the touchesEnded, I want to exec开发者_JAVA技巧ute some instructions only if the main subview was touched (and not the UIButton).

Is there a way to do this??

Thanks in advance. ezbz


Use write your logic using these events ,by comparing the coordinates accordingly .

   -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    }
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
        UITouch *aTouch = [touches anyObject];
        CGPoint point = [aTouch locationInView:self.view];
        NSLog(@"X%f",point.x);
    }

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消