标签:抓取.a文件内的事件
由于应用里面添加了弹窗的广告,但是为.a的库文件,出于好奇想抓取弹窗广告内的控件事件,于是写了如下代码测试,成功!
for (id obj in [[[UIApplication sharedApplication] keyWindow] subviews])
{
NSLog(@"Class Name[%s]", object_getClassName(obj));
NSString * str = [NSString stringWithFormat:@"%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的子View = %@",hh);
//通过打印hh得知所要获取的控件有tag值,于是根据tag值抓到对应的控件
if(hh.tag == 1)
{
UIButton * btn = (UIButton *)hh;
NSSet* myActions = [btn allTargets];
NSEnumerator * mm = [myActions objectEnumerator];
for (NSString * ss in mm)
{
NSLog(@"遍历枚举的值: %@",ss);
NSArray * array = [btn actionsForTarget:ss forControlEvent:UIControlEventTouchUpInside];
SEL sel = NSSelectorFromString(array[0]);
//sel 则为要抓取的控件事件
[ss performSelector:sel];
}
}
}
}
}
}
标签:抓取.a文件内的事件
原文地址:http://blog.csdn.net/illusion21/article/details/39959095