我在uiview中有三个webview,只显示了一个。有时当我将网址加载到未显示的网页视图,然后将它们移动到框架中心时,它们只显示白框 - 只有白色屏幕,即使他们一直说他们已完成加载。所以... 加载后是否有可能强制重绘?当我随机滚动它们时,鼓励webviews显示它们的内容...... 还有其他想法来修复这个bug吗?
代码:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
Boolean end = true;
for (int i = 0 ; i < 3 ; i ++)
{
if ( mainWebViews[i].isLoading )
{
end = false;
}
}
if (end)
{
//NSLog(@"nothing is loading?");
[loader stopAnimating];
loader.hidden = YES;
}
webView.hidden = NO;
// how to redraw here?
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
//NSLog(@"start loading");
webView.hidden = YES;
loader.hidden = NO;
[loader startAnimating];
}
-(void)webView:(UIWebView*) wv didFailLoadWithError: (NSError*) error
{
// some stupid -999 error
if ( [error code] != NSURLErrorCancelled )
{
NSLog(@"error");
NSLog( [error localizedDescription ]);
}
}
-(void)loadToWebView:(UIWebView*)wv string:(NSString*)url
{
if (wv == nil)
return;
[wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}