Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 旋转设备时出现UIWebView大小调整问题_Iphone_Objective C_Ios_Uiwebview - Fatal编程技术网

Iphone 旋转设备时出现UIWebView大小调整问题

Iphone 旋转设备时出现UIWebView大小调整问题,iphone,objective-c,ios,uiwebview,Iphone,Objective C,Ios,Uiwebview,我有一个UIWebview,其中放置了一个本地html。当ipad移动时,我会重新设置元素的范围,以便UIWebView在移动后变小/变大。问题是,虽然当我筛选和调整宽度时,虽然宽度已调整,但文本未调整。文本仅在webview的框架中可见,但它会脱离屏幕。某些文本被隐藏,它会继续到某个不可见的点。如何调整webview内容宽度 我曾经面对过这个问题,我所做的就是解决这个问题。。。创建方法 -(void)reconfigureFrame { [_yourWebView loadHTM

我有一个UIWebview,其中放置了一个本地html。当ipad移动时,我会重新设置元素的范围,以便UIWebView在移动后变小/变大。问题是,虽然当我筛选和调整宽度时,虽然宽度已调整,但文本未调整。文本仅在webview的框架中可见,但它会脱离屏幕。某些文本被隐藏,它会继续到某个不可见的点。如何调整webview内容宽度

我曾经面对过这个问题,我所做的就是解决这个问题。。。创建方法

-(void)reconfigureFrame
{
       [_yourWebView loadHTMLString:[NSString stringWithFormat:@"<html><body style='background-color: transparent; width: 280px; margin: 0; padding: 0;color:black;'><div id='ContentDiv'>%@</div></body></html>",theStringToShow] baseURL:nil];
}
在didAutoRotate中,只需调用第一个方法

即可使用webViewDidFinishLoad方法中的UIWebViewDelegate设置webView fram大小。
NSString *contentHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('ContentDiv').offsetHeight"];
CGRect frame = [containtView frame];
//containtView holds webView
frame.size.height = [contentHeight floatValue] + 10;
[containtView setFrame:frame];

frame = [webView frame];
frame.origin.x = 10;
frame.origin.y = 5;
frame.size.width = containtView.frame.size.width - 2*frame.origin.x;
frame.size.height = [contentHeight floatValue];
[webView setFrame:frame];