假定有 :
UINavigationController : A,
UIViewController : B,
UIViewController : C,
假设B是A的 rootViewController,B的title就是B,C的title就是C,
如果调用 [B.navigationController pushViewController:C animated:YES];
进入C界面后,导航栏左边会显示返回箭头和标题B,如果B太长,我们希望隐藏标题B,只显示返回按钮,
正确做法是:
B.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:listVC action:nil];
如果写成下面的样子,无法隐藏标题B:
1、A.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:listVC action:nil];
2、C.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:listVC action:nil];