I am working on an iPhone application which works in both orientations: portrait and landscape.
I am using for one view and tableview embedded in an UINavigationController. The height of this navigationbar with its buttons is either: 44px portrait or 34px landscape.
Within a different view I created the UINavigationBar by myself and I am able to set the frame for the correct size, but the embedded UINavigationItem with UIBarButtonItem doesn't shrink. So for the 34 px in the landscape mode this button is to big and overlaps the navbar in the height.
The funny thing is though, that this worked with identical code in other apps... have no idea which it isn't here.
Is there anyway to adjust the height / position of an UIBarButtonItem?
Here is the code snippet:
navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 34.0f)];
[navBar setBarStyle: UIBarStyleBlackOpaque];
[self addSubview: navBar];
barButton = [[UIBarButtonItem alloc] initWithTitle: NSLocalizedString(@"flip", @"flip") style:UIBarButtonItemStylePlain target:self action:@selector(flip)];
item = [[UINavigationItem alloc] initWithTitle: NSLocalizedString(@"Translation", @"Translation Tab Bar Title")];
[item setRightBarButtonItem: barButton];
[navBar pushNavigationItem:item animated:NO];
alt text http://labs.kiesl.eu/images/navbar.png
Thanks
Tom
I figured it out: The height of the navigation bar must be 32 px! With 33 or 34 px the alignment screws up.