0

I can not add on NavigationBar backbutton. I want to perform this operation on a ViewController, I have tried different ways, but could not reach a solution. Do you need to use Backbutton NavigationController to use, or you can perform on a ViewController? Waiting for your help.

2 Answers2

0

If your ViewController is within a navigation controller, you should be able to do this:

[self.navigationController popViewControllerAnimated:YES];
Corey
  • 5,818
  • 2
  • 24
  • 37
  • No, ViewController not in the NavigationController, I want to go back with the button back of two separate ViewController, but the back button to don't show it on the page. – Burak Benli Sep 19 '13 at 14:59
-1

Hide the default back button

    [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];
}