0

我有两个UINavigationController问题。iPhone UINavigationController问题(看不见的按钮,标题)

问题1

在初始视图我编程方式添加的rightBarButtonItem。

当我将navigationView推向右侧时,一切正常,它会显示一个带有前一个视图标题的后退按钮。

当我点击后退按钮时,我回来了。但是这个按钮不见了。但它并没有真正消失,它仅仅是看不见的,因为它仍然可以被点击。

问题2

当我推的viewController上的权利,我不能设置标题。我试了一下推观与

myViewController.title = @"someTitle"; 

之前,我和

self.title = @"someTitle"; 

试了一下还的viewController内,但没有在这里工作。

回答

1

我发现这个问题:

我添加自定义背景图片的的导航栏。不知何故,这张图片覆盖了标题/按钮。

所以,如果你想实现一个自定义的背景图片,没有用户这样:

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]; 

而是使用此:

@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 
0

问题1: 听起来很奇怪。并不是真的有这样的答案: -/

问题2: 你能提供一些更多的代码片段,就像你尝试设置标题的整个方法体?