• webViewDidFinishLoad因为网页里的重定向,会调用多次,使用web view.isLoading来解决


    我编码如下,但我发现 webViewDidFinishLoad() 会发生若干次。
    如何知道 webViewDidFinishLoad() 最后发生吗?
    iNavigate = 0;
    
    
    - (void)webViewDidFinishLoad:(UIWebView *)webView 
    {    
    
        iNavigate ++;
    
    
        NSLog(@"Navigate Count = %d", iNavigate);
    
    
        if (iNavigate >1)
        {
            CGRect rect = self.webView.frame;
            rect.size.height = rect.size.height - toolBarBrowser.frame.size.height;
            self.webView.frame = rect;
            self.toolBarBrowser.hidden = FALSE;
        }
    
        barButtonBack.enabled = (self.webView.canGoBack);
        barButtonForward.enabled = (self.webView.canGoForward);
    
    
    
    }
    
    //解决方法 1:
    //您可以使用 (webview.isLoading) 来知道 UIWebView webViewDidFinishLoad 最后或发生不
    - (void)webViewDidFinishLoad:(UIWebView *)webView{
        if (!webView.isLoading){
            [self ChickUrlIsDownload:myWebview.request.URL.absoluteString];
        }
        {
            [progress setProgress:1 animated:YES];
            [progress removeFromSuperview];
            progress=nil;
        }
        if ([myWebview canGoBack]) {
            [btn_back setSelected:YES];
        }else{
            [btn_back setSelected:NO];
        }
        [btn_back setEnabled:btn_back.selected];
        if ([myWebview canGoForward]) {
            [btn_go setSelected:YES];
        }else{
            [btn_go setSelected:NO];
        }
        [btn_go setEnabled:btn_go.selected];
        //获取到title
        NSString *title=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
        if (title.length>16) {
            sel_title=[NSString stringWithFormat:@"%@%@",[title substringWithRange:NSMakeRange(0,16)],@"..."];
        }else{
            sel_title=title;
        }
        NSLog(@"_str_title=%@",sel_title);
    }
  • 相关阅读:
    易语言常用源码
    ci的数据库地址
    格式化输出php数组
    mysql插入表情问题
    线程、进程与协程2
    线程、进程与协程
    if __name=='__main__"的作用
    动态导入模块
    面向对象补充之方法
    getpass模块
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/4610259.html
Copyright © 2020-2023  润新知