Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.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
Ios 更改网站宽度以符合UIWebView_Ios_Objective C_Cocoa Touch - Fatal编程技术网

Ios 更改网站宽度以符合UIWebView

Ios 更改网站宽度以符合UIWebView,ios,objective-c,cocoa-touch,Ios,Objective C,Cocoa Touch,每隔一段时间,我的Web视图就会遇到一个放大得太远的站点,我不在乎垂直滚动,但水平滚动可能非常烦人。到目前为止,我的代码是: -(void)zoomToFit { webView.scalesPageToFit = YES; NSInteger height = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] integerValue];

每隔一段时间,我的Web视图就会遇到一个放大得太远的站点,我不在乎垂直滚动,但水平滚动可能非常烦人。到目前为止,我的代码是:

-(void)zoomToFit
{
webView.scalesPageToFit = YES;
NSInteger height = [[webView stringByEvaluatingJavaScriptFromString:
                     @"document.body.scrollHeight"] integerValue];

NSInteger width = [[webView stringByEvaluatingJavaScriptFromString:
                    @"document.body.scrollWidth"] integerValue];

NSLog(@"%d  %d",height,width);
}

正如您所见,我有页面的高度和宽度,但我不知道如何更改“缩放”

您可以设置
UIWebView
UIScrollView
contentSize
。比如:

[yourWebView.scrollView setContentSize:CGSizeMake(width,height)];
希望这对你有用