I got a navigation controller that has a “Done” button. When the user is finished with the form, they press “Done” and I want that view popped off the stack and back at the main menu.
Here is the code I got so far:
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain
target:self
action:[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES]];
self.navigationItem.rightBarButtonItem = anotherButton;
Please help! Thank you
1) Define new method of the class that corresponds to
self. Fro example,2) Set appropriate selector when creating your button: