Reputation: 14380
I have a UINavigationController
which points to a UITableViewController
(a list of items) where there is a segue from a cell to another UITableViewController
(a screen to edit an item).
On first run of the application, I'd like to skip the first list and immediately go to the second screen, to edit a new item.
The problem is I need to pass the first UITableViewController
, as I need to be able to go back to that one (or is there a way to set the controller the back button is pointing to?).
Things I've tried and failed:
Set a boolean shouldPresentNewItem
on the UINavigationController
and in the viewDidLoad
if it is set to true
, present the first UITableViewController
, also setting a boolean so I can go to the edit screen.
Using self.navigationController!.popToViewController(arr[index] as UIViewController, animated: true)
in the UINavigationController
s viewDidLoad
. This gave an error as self.navigationController
was nil
. (I don't get why this happens)
How can this be done?
Upvotes: 0
Views: 52
Reputation: 4248
In navigation controller set some boolean indicating that you're going to show edit screen and in viewDidLoad
just push edit view controller without animation:
- (void) viewDidLoad {
[super viewDidLoad];
if (self.presentEditScreen) {
self.presentEditScreen = NO;
EditViewController *e = [[DetailViewController alloc] init];
[self pushViewController:e animated:NO];
}
}
Upvotes: 1
Reputation: 451
simplest way will be. just push from second view to first view
firstViewController *objFirstViewController = [[firstViewController alloc]initWithNibName:@"firstViewController" bundle:nil];
[self.navigationController pushViewController:objFirstViewController animated:No];
Upvotes: 0