WebView在方向更改上无法正常工作

我有一个通用的应用程序与一个webView,当发生方向更改时resize。 在iPad模拟器上,webView会自动重排以适应新的宽度。 但是,在iPhone模拟器上,内容不会重新stream动,其中一些内容会被切断。

这是一个已知的WebView错误? 我该如何解决这个问题?

我的webview只是加载一个远程的HTML页面。

我正在testingIOS 4.3

在界面构build器中,您必须调整WebView的属性,以使其在方向更改上拉伸。 确保你做到了。 它在Xcode中看起来像这样: 在这里输入图像说明

你实现这个代码很简单

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { CGRect frame = webview.frame;//UIWebView* webview; frame = self.view.frame; webview.frame=frame; NSString *embeded_url = [NSString stringWithFormat:@"<html> <head> <meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 000\"/></head><body style=\"margin-top:0px;margin-left:0px\"><div><object width=\"%f\" height=\"%f\"><param name=\"movie\" value=\"%@\"></param></object></div></body></html>",frame.size.width,frame.size.height ,video_url];//url for video [ webview loadHTMLString:embeded_url baseURL:nil];//reload the web view from cache } 

didRotateFromInterfaceOrientation:在发生方向更改时调用方法,并调整您的Web视图的大小。 我的webview只是加载一个远程HTML页面,它在4.X和5.X中工作正常