- (void)cancel {
// What should I do here?
}
// root view controller
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelButton;
[cancelButton release];
}
I added cancel button in the navigation bar.
I want to go back to the previous view from root view when cancel button is pressed.
What do I have to do in cancel? I added root view controller like this.
RootController *rootController = [[RootController alloc]initWithStyle:UITableViewStylePlain];
UINavigationController *aNavigationController = [[UINavigationController alloc]initWithRootViewController:rootController];
self.naviController = aNavigationController;
[aNavigationController release];
[rootController release];
[self.view addSubview:[naviController view]];
You can pop the view.
You can dismiss it as well.
EDIT:
If you are adding the view then you need to remove your view.