The IOS child view responds to the Click events of the parent view

Source: Internet
Author: User

Tag: BOOL responds to self targe. com nbsp delegate des Select

Recently, in order to resolve a click on a child view, it still responds to the parent's attempted click event to discover an agent method on UITapGestureRecognizer:

-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) touch

If no is returned, we can determine whether a view is in the view layer of its parent view, based on the Isdescendantofview: method. Take out the sub-view that we don't want to respond to, and if it contains this sub-view, it returns no, otherwise it is yes.

Specific wording:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initwithtarget:self

Action: @selector (Removesubviews)];

Tap.delegate = self;

self.userinteractionenabled = YES;

[Self.alpha_back_view Addgesturerecognizer:tap];

-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) touch{

if ([Touch.view IsDescendantOfView:self.tableView_back_view]) {

return NO;

}

return YES;

}

The IOS child view responds to the Click events of the parent view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.