PresentModalViewController未在下一个视图上显示导航栏 [英] PresentModalViewController not showing navigation bar on next view
问题描述
您好我正在使用工具栏上的一个标签栏按钮,此按钮将显示带有表格视图的下一个视图,这是我的代码
Hello I am using One tab bar button on toolbar , this button will show next view with table view ,Here is my code
[self presentModalViewController:self.navigationController
animated:YES];
我的问题是,当我点击此标签栏按钮时,它将显示带有tableview但未导航的下一个视图酒吧。因为这个我无法在tableView中执行删除操作。
my problem is that when I click this tab bar button it will showing next view with tableview but not navigation bar. because of this i am unable to perform delete operation in tableView.
如何解决这个问题?
推荐答案
如果你没有在下一个类上找到 UINavigationBar
,它就没有导航控制器,所以在推送它之前添加一个 UINavigationController
到你的下一个视图。
If you dont find the UINavigationBar
on the next class means , it does not have a navigation controller, so before pushing it add a UINavigationController
to your next view.
试试这样:
NextViewController *nextViewController=[[NextViewController alloc]initWithNibName:@"NextViewController" bundle:nil];
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:nextViewController];
[self.navigationController presentModalViewController:navBar animated:YES];
[navBar release];
[nextViewController release];
请参阅 stackoverflow问题。
您可以轻松地向导航栏添加按钮
You can simply add a button to navigation bar with ease
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(editTable)] autorelease];
-(void)editTable{
[tableView setEditing: YES animated: YES];
}
一切顺利。
这篇关于PresentModalViewController未在下一个视图上显示导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!