UIWebView scalesPageToFit
@property(nonatomic) BOOL scalesPageToFit
Discussion of [UIWebView scalesPageToFit]
If YES, the webpage is scaled to fit and the user can zoom in and zoom out. If NO, user zooming is disabled. The default value is NO.
UIWebView scalesPageToFit example.
- (void)viewDidLoad {
[super viewDidLoad];
webView = [[UIWebView alloc] init];
webView.scalesPageToFit = YES;
webView.backgroundColor = [UIColor blackColor];
self.view.alpha = 1;
self.view.backgroundColor = [UIColor whiteColor];
}
[super viewDidLoad];
webView = [[UIWebView alloc] init];
webView.scalesPageToFit = YES;
webView.backgroundColor = [UIColor blackColor];
self.view.alpha = 1;
self.view.backgroundColor = [UIColor whiteColor];
}
Example of [UIWebView scalesPageToFit].
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 400.0f)];
webViewT = [[UIWebView alloc] initWithFrame:view.bounds];
webViewT.delegate = self;
webViewT.scalesPageToFit = YES;
NSURL* url = [NSURL URLWithString:@"http://www.google.com/"];
[webViewT loadRequest:[NSURLRequest requestWithURL:url]];
In Some of cases this types of problem Generated. At that time java script use for control of Zoom of UIWebView, use following code.
NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];
webViewT = [[UIWebView alloc] initWithFrame:view.bounds];
webViewT.delegate = self;
webViewT.scalesPageToFit = YES;
NSURL* url = [NSURL URLWithString:@"http://www.google.com/"];
[webViewT loadRequest:[NSURLRequest requestWithURL:url]];
In Some of cases this types of problem Generated. At that time java script use for control of Zoom of UIWebView, use following code.
NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];
UIWebView scalesPageToFit example.
In my experience, you need to set scalesPageToFit before the UIWebView loads. This means setting before viewDidLoad etc. What I do is set it in "shouldStartLoadWithRequest"
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//make sure that the page scales when it is loaded :-)
theWebView.scalesPageToFit = YES;
return YES;
}
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//make sure that the page scales when it is loaded :-)
theWebView.scalesPageToFit = YES;
return YES;
}