iPhone SDK:使用导航栏打开 TableViewController
我现在正在创建我的第一个 iPhone 应用程序,尽管我遇到了一些障碍,但它进展顺利。我正在尝试打开我的设置视图(UITableViewController),尽管导航栏不会显示...我已成功打开视图,只是无法显示导航栏。这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:NO];
self.title = @"Settings";
UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:nil];
self.navigationItem.rightBarButtonItem = saveItem;
[saveItem release];
}
如果我做错了什么,请告诉我。
I'm creating my first iPhone app at the moment and it's going great, though I've come to a bump in the road. I'm trying to open up my settings view (a UITableViewController), though the navigation bar won't show up... I've successfully made the view open, just can't get the navigation bar to show up. Here's my code:
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:NO];
self.title = @"Settings";
UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:nil];
self.navigationItem.rightBarButtonItem = saveItem;
[saveItem release];
}
If I'm doing something wrong, tell me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将导航控制器作为子视图添加到主视图中。
例如,
[window addSubview:NavigationController.view]
You have to add the navigation controller as a sub view to the main view.
for example,
[window addSubview:NavigationController.view]