views:

38

answers:

1

Hi,

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:@"http://www.test.com/shop/index.php"]]];
}
A: 

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.

Tony
Thanks! It works perfectly.
STeN