I created one UIView whose frame is a little smaller than the whole screen, especially for the width.
In the UIView, I put one UIWebView and 2 buttons. The width of the UIWebView is equal with the width of the UIView, and narrower than the screen width. Then when I load some web content into the webView, the content width is not exactly equal with webView's width. Seems the content width is equal with the screen width, so it is definitely wider then the width of the UIView I created. Please take a look at these 2 screenshots.
I mean, the web content's frame is wider than the frame of its container UIView, especially the width part. This is really trick to me. I tried the setScalesPageToFit and the width-modify-tip using stringByEvaluatingJavaScriptFromString, and still can not let the content exactly fit the UIWebView. Anybody help me? Thanks very much!
Finally, fix it. UIWebView has many properties and methods.
{
NSString *policyLink = @"http://www.yahoo.com";
NSURL *url = [NSURL URLWithString:policyLink];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
_webViewPolicy.scrollView.directionalLockEnabled = YES;
_webViewPolicy.paginationMode = UIWebPaginationModeTopToBottom;
_webViewPolicy.paginationBreakingMode = UIWebPaginationBreakingModePage;
_webViewPolicy.pageLength = _viewFrame.size.width;
[_webViewPolicy loadRequest:request];
}
See the screenshot below: