2011-12-18 29 views
0

我有一个带有webView的通用应用程序,它在发生定位更改时调整大小。 在iPad模拟器上,webView会自动重排以适应新的宽度。 但在iPhone模拟器上,内容不会重新流动,其中一些内容会被切断。WebView在定位更改时无法正常工作

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

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

我的IOS 4.3

回答

0

测试在界面生成器,你必须调整的WebView的特性,使其在伸展方向改变。确保你做到了。它看起来像这样在Xcode: enter image description here

-1

这是非常简单的,你实现这个代码

- (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

相关问题