消息关闭
    暂无新消息!

代码如下:


- (void)viewDidLoad {
    [super viewDidLoad];
    
//创建webview
    UIWebView  *myWebView = [[UIWebView alloc]initWithFrame:self.view.frame];
    myWebView.delegate = self;
    [self.view addSubview:myWebView];
    
  
    
    //load地址
    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://174.3.4.119:8082/"]]];
    
    }
    
    
   - (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"加载完毕"); 
    
    NSDictionary *nativDic = @{@"appJumpUrl":@"/login"};
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:nativDic options:NSJSONWritingPrettyPrinted error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    [webview stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.__bridgeJump(%@)",jsonString]];
    
    
} 
    
    
    以上,当前的webview视图是通过另外一个webview检测用户登陆情况,未登陆的情况下跳转过来,跳转到当前视图后我回在webViewDidFinishLoad给web端返回一个字符串告诉它我想要打开的界面,然而现在奇怪的是webViewDidFinishLoad并不是每次都会执行,有的时候就执行,正常打开登陆视图,有的时候webViewDidFinishLoad方法一直不进来
    

1个回答

︿ 1

webViewDidFinishLoad是加载成功的时候才会调用,加载失败的时候不会调用,会调用didFailLoadWithError.