开发者

UIWebView on iPad size

I am using the UIWebView on iPad, which I initialize by the code below. The problem is that the view is never displayed on the top of the page just under the Status bar, but there is another 44px space (filled with black color) - for Navigation Bar, which I do not want to display. Any hints how I can make the UIWebView be displayed without the 44px space?

Thanks a lot,

BR

STeN

- (void)viewDidLoad
{
 [super viewDidLoad];
 CGRect rectApp = [[UIScreen mainScreen] applicationFrame];

 self.webView = [[[UIWebView alloc] initWithFrame:rectApp] autorelease];
 self.webView.backgroundColor = [UIColor whiteColor];
 self.webView.scalesPageToFit = YES;
 self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
 self.webView.delegate = self;

 [self.view addSubview: self.webView];
 [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"h开发者_运维知识库ttp://www.test.com/shop/index.php"]]];
}


The problem is that the coordinate system of the view you're adding it to isn't the coordinate system of the window; the view has already been adjusted for the status bar.

Change it thus:

CGRect rectApp = [[UIScreen mainScreen] applicationFrame];
rectApp.origin = CGPointZero;

Or better yet, use self.view.bounds, since self.view presumably refers to a view that fills the application's window anyway.


I like Tony's answer. When I ran into this problem I used the generic view.frame = self.view.bounds, in your code this would be written:

self.webView.frame = self.view.bounds;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜