vrwim
vrwim

Reputation: 14380

Go to second viewcontroller in NavigationViewController

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:

How can this be done?

Upvotes: 0

Views: 52

Answers (2)

lupatus
lupatus

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

Nitin
Nitin

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

Related Questions