I have a simple UIViewController with just a UIWebView. The UIWebView should take all available space to show the content of an url.
I would like to reuse this ViewController in various places. In some cases it will be pushed into a NavigationController, in some it will be shown as a ModalViewController. Sometimes it might be inside a TabBarController. The size of the UIWebView will vary from case to case.
What's the best way to set the frame of the UIWebView without using the Interface Builder? In other words, how should I initialize webViewFrame in the following code? Or is there something else I'm missing?
- (void)viewDidLoad {
[super viewDidLoad];
UIWebView* webView = [[UIWebView alloc] initWithFrame:webViewFrame];
webView.delegate = self;
NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
}
I have tried with different possibilities (self.view.frame, self.navigationController.view.frame, etc.), but nothing seems to work for all cases.
Thanks!