UIWebView 最初不会加载某些 URL [英] UIWebView does not initially load certain URLs

查看:21
本文介绍了UIWebView 最初不会加载某些 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIWebView 有这么一个奇怪的问题,我一直没能在网上找到解决方案.我有一个带有网络视图的 iPad 应用程序.在第一次安装和运行应用程序时,我尝试加载一个教育网站.Web 视图只是挂起并超时.我杀死了应用程序,我再次运行它,它加载得很好.这个很好用,这也是教育网站的一部分.我要拔头发!

Having such a bizarre issue with the UIWebView and I haven't been able to find a solution online. I have an iPad app that has a web view in it. Upon first install and run of the app, I try to load an education website. The web view just hangs and times out. I kill the app, I run it again, and it loads just fine. This one works fine which is also part of the education website. I'm pulling my hair out!

一些代码:

-(void)viewDidAppear:(BOOL)animated
{
   NSURL *websiteUrl = [NSURL URLWithString:@"http://my.tac.edu.au"];
   NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL: websiteUrl];
   [self.webView loadRequest:urlRequest];
}

适用于 www.tac.edu.au.我不知道该 URL 是什么让它在应用程序首次安装时挂起.你停止它,再次运行它(不卸载),它就很好了.任何帮助将不胜感激.

Works fine with www.tac.edu.au. I don't know what it is about that URL that makes it hang only when the app is first installed. You stop it, run it again (without uninstalling) and it comes up just fine. Any help would be appreciated.

推荐答案

:)

不是view出现,而是在view中写代码出现

instead of view did appear , write the code in view will appear

-(void)viewWillAppear:(BOOL)animated
{
   NSURL *websiteUrl = [NSURL URLWithString:@"http://my.tac.edu.au"];
   NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL: websiteUrl];
   [self.webView loadRequest:urlRequest];
   self.webview.delegate = self;
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
  //Start Activity Indicator
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{

   //End activity indicator
}

这篇关于UIWebView 最初不会加载某些 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆