0

I have a problem I want to control the backBarButtonItem when I click on it Action backAction "works my problem is that SetAction does not work, I hope there is a solution for the controller backBarButtonItem

- (void)viewDidLoad {

    [self.navigationItem.backBarButtonItem setTarget:self];
    [self.navigationItem.backBarButtonItem setAction:@selector(backAction)];


    [super viewDidLoad];
}

- (void)backAction {
    if ((isSaveCarte==NO)&&(isNewCarte)) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Voulez vous Enregistrer la Carte" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Save",nil]; 

        [alertView show]; 
        [alertView release];                
    }
 }

enter image description here

Vladimir
  • 170,431
  • 36
  • 387
  • 313
YasBES
  • 2,365
  • 3
  • 21
  • 33

2 Answers2

0

back bar button item is meant for navigating back...

why don't you use the leftBarButtonItem instead of backBarButtonItem.. the only difference would be it wont be a left pointed button.. but you are not navigating back anyways right?

Swapnil Luktuke
  • 10,385
  • 2
  • 35
  • 58