我正在创建一个应用程序,需要一半的页面为web视图,另一半需要填充其他内容。问题是,当我在UI构建器中布局视图时,它的宽度和高度是正确的,但是当我实际加载它时,会填充整个屏幕。iOS中的UIWebView
下面的代码:
- (void)loadView
{
// Create a custom view hierarchy.
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
UIView *view = [[UIView alloc] initWithFrame:appFrame];
self.view = view;
[view release];
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webView = [[UIWebView alloc] initWithFrame:webFrame];
webView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:webView];
NSString *html = @"<html><head><title>Should be half</title></head><body>I wish the answer were just 42</body></html>";
[webView loadHTMLString:html baseURL:nil];
}