UIWebView获取跳转链接

来源:互联网 发布:淘宝二手回收可信吗 编辑:程序博客网 时间:2024/06/03 22:48

       首先创建一个UIWebView,设置代理方法shouldStartLoadWithRequest,在该代理方法中即可获取跳转的url,每跳转一次都会执行该方法。


       UIWebView * webView = [[UIWebViewalloc] init];

        webView.frame =CGRectMake(0,0, FViewWidth,FViewHeight-50);

        webView.delegate =self;

        [self.viewaddSubview:webView];

        webView.backgroundColor = [UIColorwhiteColor];

        NSURLRequest *request = [[NSURLRequestalloc] initWithURL:[NSURLURLWithString:BeforeZhouBannerAPI]];

        [webViewloadRequest:request];



- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

{


    NSString  * url = request.URL.absoluteString;

    

    returnYES;

}

0 0