Just went through hell trying to add a static image (banner of sorts) to an iPhone application above the UINavigationBar. The project is using Three20 and this made it even more difficult.
My solution was to actually create a second window, and add that window reference to TTNavigator:
CGRect rect = [[UIScreen mainScreen] applicationFrame];
self.window = [[UIWindow alloc] initWithFrame:rect];
[self.window addSubview:[BrandingBannerView getBanner]];
self.window.hidden=NO;// makeKeyAndVisible];
rect.size.height-=50;
rect.origin.y+=10;
UIWindow *window2=[[[UIWindow alloc] initWithFrame:rect] autorelease];
[window2 makeKeyAndVisible];// [self.window addSubview:window2];
TTNavigator *navigator = [TTNavigator navigator];
navigator.window =window2;
The above code creates the application’s main window, then adds the banner to it. Then it creates another window, makes it key and visible, but using a smaller frame to accomodate the top banner.
Then in Three20’s code, TTGlobalUINavigation.m, I changed these functions:
CGRect TTScreenBounds() {
CGRect bounds =[UIApplication sharedApplication].keyWindow.frame; // [UIScreen mainScreen].bounds;
if (UIInterfaceOrientationIsLandscape(TTInterfaceOrientation())) {
CGFloat width = bounds.size.width;
bounds.size.width = bounds.size.height;
bounds.size.height = width;
}
return bounds;
}CGRect TTNavigationFrame() {
CGRect frame = [UIApplication sharedApplication].keyWindow.frame; // [UIScreen mainScreen].applicationFrame
return CGRectMake(0, 0, frame.size.width, frame.size.height – TTToolbarHeight());
}
This allowed things to work correctly.
Leave a Reply
You must be logged in to post a comment.