I have add the navigationItem.backBarButtonItem
when turn to the new page like the following code , but I want to add a Timer
for change some image before turn back to the first by backBarButtonItem
.
UIViewController *ReconnectView = [[AITReconnectView alloc] initWithNibName:@"AITReconnectView" bundle:nil] ;
ReconnectView.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style:UIBarButtonItemStyleBordered target:nil action:nil];
[self.navigationController pushViewController:ReconnectView animated:YES];
For example : When I click the backBarButtonItem
, it will run the Timer
for 3 second. And then turn back to the first view.
I have search for some information , but it only overwrite the new method for backBarButtonItem
.
How to add a Timer
in method of backBarButtonItem
but retain the original method of backBarButtonItem
?
Thanks in advance.
There are two ways:
Create your own back button (similar like native) and selector method and assign it to button:
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithTitle:@"BackToVcA" style:UIBarButtonItemStyleBordered target:self action:@selector(addAction:)] autorelease]; self.navigationItem.rightBarButtonItem = addButton;
Use UIViewController life cycle method, viewWillDisappear
or viewDidDisappear
.
Hope this is what you're looking for.