I can't perform a transition between viewControllers
because navigationController
is nil
. I have logged navigationController
in different parts of the class
but it returns nil everywhere. In storyboard
the viewController
is embedded in a navigationController
. I have checked other threads on SO
with the same issue, but none of the answer has helped or even really made sense to me.
Can't push because self.navigationController is nil
navigationController is nil,when push the viewcontroller
Why is it nil? And how do I solve this? An error message is also returned:
I have tried both using a segue
:
[self.navigationController performSegueWithIdentifier:@"experienceDetails" sender:self];
as well as pushing:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Inspiration" bundle:nil];
ExperienceViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"experience"];
[self.navigationController pushViewController:viewController animated:NO];
Nothing happens using push
but an error message is produced:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior
I have looked for solutions on that error too, but there doesn't seem to be a clear and concrete answer to how to solve it. Again, those suggestions I read and tried didn't work.
I'm really at a loss here. Such a simple thing to do but I'm hindered by something I don't even understand.
EDIT
If it helps, I have a tab bar
and in one item
I have the viewController
that is embedded in a navigationController
and from there I want to push
to another viewController
within the same storyboard
.
EDIT I got this to work:
[self showViewController:viewController sender:self];
very likely because it doesn't use navigationController
. Its presented as modular
though and is not part of the navigation stack, which is not something I want. Just good to know that things would work if navigationController
wasn't nil.
I reproduced the described behaviour when segue experienceDetails was created from navigation controller... and here is solution
1) deleted segue experienceDetails form navigation controller
2) created push
segue with identifier experienceDetails from included view controller to detail view controller
3) in view controller performed segue from self
as below
[self performSegueWithIdentifier:@"experienceDetails" sender:self];