In iOS, if the position of the button exceeds the parent view, it cannot respond. How do I handle it?

Source: Internet
Author: User

Override the following methods in the parent view where the button resides.

In the following example, I added two buttons outside the parent view callbtn and DETAILBTN;

The following example scenario is a custom bubble view in the. Gold map. Because the bubble view is added by default on the Pin view. In general, the size of the pin view is much smaller than the bubble view and the bubble view is all outside the pin view. Unable to respond to click events.

-(UIView *) HitTest: (cgpoint) point withevent: (uievent *) event {

UIView *view = [super hitTest:p oint withevent: event]; Get the view of the response event first by normal method

if (view = = Nil) {

        cgpoint TEMPOINTCALLBTN = [self. Calloutview. Callbtn convertpoint:p oint fromview :self

        cgpoint TEMPOINTDETAILBTN = [self. Calloutview. Detailbtn convertpoint:p oint fromview:self;//If you want to judge multiple buttons, add the corresponding points multiple times according to this rule. After the IF statement, add the corresponding else if judgment.

if (cgrectcontainspoint(self). Calloutview. Callbtn. Bounds, TEMPOINTCALLBTN)//Determine if the location of the current click is in the view we want to respond to.

{

View = self. Calloutview. CALLBTN;//If the judge is true, return the view we want to respond to.

} Else if (cgrectcontainspoint( self). Calloutview. Detailbtn. Bounds, tempointdetailbtn)) {

View = self. Calloutview. DETAILBTN;

}

}

return view;

}

In iOS, if the position of the button exceeds the parent view, it cannot respond. How do I handle it?

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.