0

我无法添加 NavigationBar 后退按钮。我想在 ViewController 上执行此操作,我尝试了不同的方法,但无法找到解决方案。是否需要使用Backbutton NavigationController来使用,或者可以在一个ViewController上执行?等待您的帮助。

4

2 回答 2

0

如果您的 ViewController 在导航控制器中,您应该可以这样做:

[self.navigationController popViewControllerAnimated:YES];
于 2013-09-19T14:51:32.003 回答
-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];
}
于 2013-09-20T10:59:01.157 回答