UITableViewController 中的导航项没有出现?
我正在以模态方式呈现的 UITabBarController 内部显示一个 UITableViewController:
-(IBAction)arButtonClicked:(id)sender{
//this is a uitableviewcontroller
ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease];
LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease];
lbViewController.title = @"Leaderboard";
arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil];
arTabBarController.selectedViewController = arViewController;
[self presentModalViewController:arTabBarController animated:YES];
}
在我的 arViewController 方法的 viewDidLoad 中,我正在设置导航项:
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
self.title = @"AR";
leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(leaderBoardButtonClicked:)];
self.navigationItem.rightBarButtonItem = leaderBoardButton;
}
当我的导航栏位于 UITabBarController 内部时,它不会出现,但当我推送视图本身时,它不会出现我能看到它。
我缺少什么?
I am displaying a UITableViewController inside of a UITabBarController that is being presented modally:
-(IBAction)arButtonClicked:(id)sender{
//this is a uitableviewcontroller
ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease];
LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease];
lbViewController.title = @"Leaderboard";
arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil];
arTabBarController.selectedViewController = arViewController;
[self presentModalViewController:arTabBarController animated:YES];
}
In my viewDidLoad for arViewController method I am setting the navigation items:
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
self.title = @"AR";
leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(leaderBoardButtonClicked:)];
self.navigationItem.rightBarButtonItem = leaderBoardButton;
}
My navigation bar doesn't appear when it is inside of the UITabBarController, but when I push the view itself I am able to see it.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
呵呵,我也被这个问题难住了。您需要做的就是发送 rootViewController。
除了在主屏幕上之外,我从未使用过 tabBar,但你的代码可能如下所示:
after arTabBarController.selectedViewController = arViewController;
就像我说的,我还没有用 tabBar 做过,但我很确定它会是这样的
Heh, I've been stumped by this too. What you need to do is send the rootViewController.
I've never used a tabBar for anything except on the main screen but ur code will probably look like this:
after arTabBarController.selectedViewController = arViewController;
Like I said I haven't done it with a tabBar but I'm pretty sure it will be something along these lines
我需要添加一个 UINavigationBar:
I needed to add a UINavigationBar:
有一个简单的解决方案,将设置放在视图中就会出现,
希望对新手有帮助;
There is a simple solution, put setting in view will appear
hope it help some newbies;