我如何自定义导航返回按钮在iOS 7及以上没有标题?(即只使用箭头)
self.navigationItem.leftBarButtonItem = self.editButtonItem;
我只是想知道它们是否有self。backbuttonitem;
OR
像这样的东西?
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemBACK
target:self action:@selector(back)];
你不能以你想要的方式访问导航backButtonItem,你需要创建自己的返回按钮,如下所示:
- (void)loadView
{
[super loadView];
UIButton *backButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 44.0f, 30.0f)];
[backButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(popVC) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
}
当然了:
- (void) popVC{
[self.navigationController popViewControllerAnimated:YES];
}