I am trying to get a webpage to fit to the iPhone screen using Xcode, but at the bottom of the screen I put a textbox to allow a user to enter in a username. This means that the webview box is a little bit smaller than using the full screen. I know how to make webpage fit to the full screen, but how do you fit it in a frame smaller than the full iPhone screen?
Start with a UIView in IB that is the full size of the screen and then put your web view and text fields inside it. You should then be able to resize the web view.
Init with frame:
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, width, height)];
CGFloat x = 0; CGFloat y = 0; CGFloat width = self.view.frame.size.width; CGFloat height = self.view.frame.size.height - 30; UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, width, height)]; [self.view addSubview:webView]; // Add the webview to the main view
This will make the height of the
webView 30 points less than the main view you are adding it to.