我从NavigationViewController模板开始我的xcode项目.现在,当我按下视图时,该视图默认情况下会出现一个编辑按钮而没有后退按钮.我已经注释掉editButton代码和相应的setEditing委托方法.但是我无法显示后退按钮.我究竟做错了什么?
推动新视图:
PlaylistViewController *playlistViewController = [[PlaylistViewController alloc] init];
playlistViewController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:playlistViewController animated:YES];
[playlistViewController release];
Run Code Online (Sandbox Code Playgroud)
在我的PlaylistViewController中:
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"";
// self.navigationItem.leftBarButtonItem = self.editButtonItem;
// doesn't matter if this is here or not
self.navigationItem.hidesBackButton = false;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
}
Run Code Online (Sandbox Code Playgroud)
当你告诉UINavigationController pushViewController时,它会自动将navigationItem.leftBarButtonItem设置为一个带有前一个UIViewController标题标题的按钮.
如果未设置标题,则默认文本为"返回".
如果标题设置为"",则根本不会显示任何按钮.
self.title = @"";
Run Code Online (Sandbox Code Playgroud)
尝试更改此文本,后退按钮应与此处设置的文本相匹配.
或者,您可以从新的UIViewController 手动覆盖leftBarButtonItem的文本.
| 归档时间: |
|
| 查看次数: |
3892 次 |
| 最近记录: |