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