5 uiwebview uiviewcontroller ios5 ios6
关于这个问题有一些问题,它有关于嵌入在html字符串中的脚本的解决方案.不是我的情况.
我有一个ios5/6应用程序.我试图将加载代码置于initWithNibName糟糕的主意,viewDidLoad不推荐使用,所以viewWillAppear离开了.
- (void) viewWillAppear:(BOOL)animated
{
NSString* detailHtml = [Storage getDetailHtml: -1];// get the last one
//NSLog(@"detailHtml: %@", detailHtml);
if(detailHtml == nil){
NSLog(@"Can't load the detail");
detailHtml = @"<html><body>Some text here</body></html>";
}
[webView loadHTMLString:detailHtml baseURL:nil];
[super viewWillAppear:animated];
}
Run Code Online (Sandbox Code Playgroud)
此代码的问题是闪烁.看来UIViewContoller,用白色webView比1-2秒后显示html.HTML有一些文本,但也有base64编码的图像,有时它大约3Mb甚至5MB的内容.这里没有javascript,只是内联CSS(没有外部文件),文本和base 64编码图像.
我可以预加载到detailHtml文本中,但我认为显示需要更多时间.
是否可能不显示ViewController,直到webView还没有完成加载html? - 一些回调?
有什么建议?
加载HTML字符串UIActivityIndicator默认值会花费一点时间,但是如果一切正常,那么为什么不放置它呢?这样可以使用户与应用保持互动,这比保持空白更好
这是一种委托方法UIWebView:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//And stop your indicator over here
[indicator stopAnimating];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2702 次 |
| 最近记录: |