I want to implement a "Next" feature in my app. The button appears on a ViewController
that is shown by clicking on a row in a UITableView
. Ideally what I would like is for Next to do the following (in pseudo code)
- Go "back" to the
UITableView
- Scroll to next available item in
UITableView
- Select that item
I believe I can do 2,3 via selectRowAtIndexPath
(please feel free to correct me if I am wrong) but I am unsure how to do Step 1. I will also have to target a method in the UITableView
rather than the UIViewController
that hosts the Button. How would I achieve this?
Update:
I can now target the rootViewController but now do I actually show it? (For reference here is my code, thanks to this question)
NSArray *viewControllers = self.navigationController.viewControllers;
UIViewController *rootViewController = [viewControllers objectAtIndex:viewControllers.count - 2];
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:rootViewController action:@selector(nextButton:)];
Update 2
I now have the back animation working but it keeps the navigation bar intact, how do I also set this back to the correct (rootViewController) one?
[self.navigationController popToRootViewControllerAnimated:YES];