I am setting the values of the title and back button in the UINavigationBar
as follows:
self.navigationItem.title = @"Post";
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [[UIColor blueColor] colorWithAlphaComponent:0.75f],
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue" size:20]}];
[self.navigationController.navigationBar.backItem setTitle:@"Pop Pop !"];
But i am unable to add target to the backbutton. I have tried the following:
[self.navigationItem.backBarButtonItem setTarget:self];
[self.navigationItem.backBarButtonItem setAction:@selector(goBack:)];
and
self.navigationItem.backBarButtonItem.target = self;
self.navigationItem.backBarButtonItem.action = @selector(goBack:);
But my selector is not being invoked on popping the viewController.
How do I add a target to the backButton, or invoke a selector on popping the viewController ? (I have tried all possible solutions mentioned in SO, in vain)
EDIT: I would to prefer to edit the behaviour of the stock backButton, instead of setting a custom button as the backButton.