I know there a lot of similar questions to this, but I didn't find any that helped me out. I made a webView that displays a url that has a survey on it, but the content isn't shrinking to the size of the screen. Can somebody tell me what I need to write to just get the content to shrink to the screen size, and where I put it? Any help would be greatly appreciated.
- (void)viewDidLoad
{
NSString *website =@"http://www.nameofwebsite.com";
NSURL *url = [NSURL URLWithString:website];
NSURLRequest *requestURL =[NSURLRequest requestWithURL:url];
webView.scalesPageToFit = YES;
webView.autoresizesSubviews = YES;
[webView loadRequest:requestURL];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
The statement
webView.scalesPageToFit = YES;
should size the web page to fit the size of the UIWebView. The user then has the option to zoom in and out of the page. Your problem might be because the webview is not located properly. If your view controller's view fits the screen entirely, add this to your code.
webView.frame=self.view.bounds;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With