Objective c 为什么我的UInavigationController右按钮在加载后消失
我使用以下代码在用户单击UIButton时按下视图控制器Objective c 为什么我的UInavigationController右按钮在加载后消失,objective-c,ios,uitableview,uinavigationcontroller,Objective C,Ios,Uitableview,Uinavigationcontroller,我使用以下代码在用户单击UIButton时按下视图控制器 - (IBAction)showListPicker:(id)sender { if([audioPlayer isPlaying]) { [audioPlayer stop]; } ListPicker *lp = [[ListPicker alloc] initWithStyle:UITableViewStyleGrouped]; [[self navigationContr
- (IBAction)showListPicker:(id)sender {
if([audioPlayer isPlaying])
{
[audioPlayer stop];
}
ListPicker *lp = [[ListPicker alloc] initWithStyle:UITableViewStyleGrouped];
[[self navigationController] pushViewController:lp animated:YES];
[lp release];
}
在ListPicker的ViewDidLoad中,我使用以下代码添加右导航控制按钮
-(void)viewDidLoad{
[[self navigationController] setNavigationBarHidden:NO];
[[[self navigationController] navigationBar] setTintColor:[UIColor brownColor]];
[[self view] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(doSomething:)];
[[self navigationItem] setRightBarButtonItem:button];
[button release];
}
加载视图时,我可以短暂地看到右侧按钮,但随后它立即消失。我做错了什么
谢谢。我猜您的ListPicker的XIB包含另一个导航栏,妨碍了实际的导航控制器栏。这就是为什么你看到它一瞬间,然后它就“消失”了。如果不是XIB中的内容,请检查代码,从实例化新的视图控制器一直到ListPicker的ViewDid出现。您的代码工作正常。我认为您的剩余代码还有一些其他问题。我认为您是对的。该代码在“我的另一个视图”上运行,但在该视图上不起作用。是的,请检入剩余代码。如果找到解决方案,则该解决方案很好,否则请发布剩余代码…ListPicker没有XIB。它是UITableViewController的一个子类。在什么情况下右键消失的最佳方式是什么?在ListPicker.m中,除了viewDidLoad之外,没有任何东西可以触摸导航控制器。