UINavigationController: how to control the Cancel and Back buttons

Suppose I have two controllers A and B ... When I move from A to B, then the Back button on B Controller will be A.

So, my problem ... By clicking on the button, I have to change the backButton to the "Cancel" button .. and on the other "Back" button it should appear backButton A in the style of the arrow of the "Back" button.

Please offer.

+4
source share
1 answer

Do the following

In the SHOW Cancel button:

- (void)showCancelButton { UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(someMethod)]; [self navigationItem] setLeftBarButtonItem:cancelButton]; [cancelButton release]; } 

To Hide the Cancel button:

 - (void)hideCancelButton { [self navigationItem] setLeftBarButtonItem:nil]; } 

Make sure self.navigationController.navigationItem.hidesBackButton is NOT .

+9
source

All Articles