抓取第三方廣告彈窗裡的控制項事件-測試成功

來源:互聯網
上載者:User

標籤:抓取.a檔案內的事件


由於應用裡面添加了彈窗的廣告,但是為.a的庫檔案,出於好奇想抓取彈窗廣告內的控制項事件,於是寫了如下代碼測試,成功!



 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的子View = %@",hh);

 //通過列印hh得知所要擷取的控制項有tag值,於是根據tag值抓到對應的控制項

                    if(hh.tag == 1)

                    {

                       UIButton * btn = (UIButton *)hh;

                        

                       NSSet* myActions = [btn allTargets];

                                             

                       NSEnumerator * mm = [myActions objectEnumerator];

                        

                       for (NSString * ssin mm)

                        {

                           NSLog(@"遍曆枚舉的值: %@",ss);

                            

                           NSArray * array = [btn actionsForTarget:ssforControlEvent:UIControlEventTouchUpInside];

                            

                           SEL sel = NSSelectorFromString(array[0]);

                           //sel 則為要抓取的控制項事件

                            [ssperformSelector:sel];

                            


                        }

                        

                    }

                    

                }

            

            }

    

        }

        

    }


抓取第三方廣告彈窗裡的控制項事件-測試成功

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.