Reputation: 27394
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)
UITableView
UITableView
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];
Upvotes: 1
Views: 211
Reputation: 2468
If you have situation like this:
When you issue [self.navigationController popToRootViewControllerAnimated:YES]; from the 2. controller by pressing the Next button, it will bring RootViewController to the screen.
Now, on the RootViewController you have to "detect" back action (perhaps in ViewWillAppear) and continue with your steps 2. and 3.
Upvotes: 1