Capture control events in third-party ad pop-up window-test successful

Source: Internet
Author: User

Tag: capture events in the. A file


Because the application adds pop-up window ads, but the. A library file, out of curiosity, wants to capture the control events in the pop-up window ads, so I wrote the following code to test the success!



For (id obj in [[[uiapplicationsharedapplication] keywindow] subviews])

{

Nslog (@ "class name [% s]", object_getclassname (OBJ ));

Nsstring * STR = [nsstringstringwithformat: @ "% s", object_getclassname (OBJ)];

If ([STR isequaltostring: @ "uiview"])

{

For (uiview * VV in [(uiview *) OBJ subviews])

{

Nslog (@ "uiview = % @", vv );

For (uiview * hh in vv. subviews)

{

Nslog (@ "uiview subview =%@", HH );

// Print HH to know that the control to be obtained has a tag value, so the corresponding control is captured based on the tag Value

If (HH. Tag = 1)

{

Uibutton * BTN = (uibutton *) HH;

Nsset * myactions = [BTN alltargets];

Nsenumerator * Mm = [myactions objectenumerator];

For (nsstring * ssin mm)

{

Nslog (@ "enumerate over enumerated values: % @", SS );

Nsarray * array = [BTN actionsfortarget: ssforcontrolevent: uicontroleventtouchupinside];

Sel sel = nsselectorfromstring (array [0]);

// Sel indicates the control event to be crawled.

[Ssperformselector: sel];


}

}

}

}

}

}


Capture control events in third-party ad pop-up window-test successful

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.