我无法添加NavigationBar后退按钮。我想在ViewController上执行此操作,我尝试了不同的方法,但无法达成解决方案。您是否需要使用Backbutton NavigationController,或者您可以在ViewController上执行? 等待你的帮助。
答案 0 :(得分:0)
如果您的ViewController在导航控制器中,您应该可以这样做:
[self.navigationController popViewControllerAnimated:YES];
答案 1 :(得分:-1)
隐藏默认后退按钮
[self.navigationItem setHidesBackButton:YES animated:YES];
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backBtnImage = [UIImage imageNamed:@"back_arrow.png"] ;
[backBtn setBackgroundImage:backBtnImage forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(goback) forControlEvents:UIControlEventTouchUpInside];
backBtn.frame = CGRectMake(0, 0, 35, 23);
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:backBtn] ;
self.navigationItem.leftBarButtonItem = backButton;
- (void)goback
{
[self.navigationController popViewControllerAnimated:YES];
}