Reputation: 3368
I have two problems with the UINavigationController.
Problem 1
On the initial view I programmatically added a rightBarButtonItem.
When I push the navigationView to the right, everything works right and it appears a back button with the title of the previous view.
When I click the back button, I get back. But then this button is gone. But it's not really gone, it's just invisible, because it can still be clicked.
Problem 2
When I push the viewController on the right, I can't set the title. I tried it before pushing the view with
myViewController.title = @"someTitle";
and I tried it also inside of the viewController with
self.title = @"someTitle";
but nothing works here.
Upvotes: 0
Views: 595
Reputation: 3368
I found the problem:
I was adding a custom background image to the navigationBar. Somehow this image got over the title / button.
So if you ever want to implement a custom background image, don't user this:
UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
[backgroundImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headerBg" ofType:@"png"]]];
[navigationController.navigationBar insertSubview:backgroundImage atIndex:0];
[backgroundImage release];
But instead, use this:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"headerBg.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
Upvotes: 1
Reputation: 1
Problem 1: Sounds odd. Don't really have an answer for that :-/
Problem 2: Can you provide some more code snippets on this, like the whole method bodies where you tried to set the title?
Upvotes: 0