Call pushViewController after currentViewController is down

I present my view controller as follows:

[self.navigationController presentViewController:self.thingContainerViewController animated:YES completion:nil]; //self.navigationController not nil here

A UITableView is displayed here. Here I want to push VC on the navigation stack. But self.navigationController is currently nothing. Any idea how to make this work?

[self.navigationController pushViewController:otherContainer animated:YES]; //self.navigationController is nil at this point
+4
source share
1 answer

You need to wrap the view controller that you represent in the navigation controller in order to use the push and pop methods.

So for the first step:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.thingContainerViewController];

Then:

[self.navigationController presentViewController:navigationController animated:YES completion:nil];

If you do, your code will work.

+4
source

Source: https://habr.com/ru/post/1599410/


All Articles