Reputation: 3749
How can I present a modalViewController from a different view controller?
I am currently displaying my modal view like this:
[self presentModalViewController:navController animated:YES];
But, I want to
[OtherViewController presentModalViewController:navController animated:YES];
Because part of it is being hidden by another viewController that is above it and manages the "self" view.
Upvotes: 0
Views: 567
Reputation: 2901
Well it should work, but maybe you are in a corner case.
Try adding a static method to your delegate like:
+ (void)presentModalViewController:(UIViewController *)viewController;
Where you do something like
[parentViewController presentModalViewController:viewController animated:YES];
And use it to present the modal view directly from the parent VC.
Anyway, if you still have a problem, give us some code :-) or your app archi.
Upvotes: 1
Reputation: 9451
It simply does not work b/c there is now such class method declared in a UIViewController class.
You are trying to call (note the + sign in front):
+ (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
UIViewController class only provides implementation for an instance method (note the - sign in front):
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
What should this tell you?
It tells you that you need to have a link to a live OtherViewController
object to be able to invoke presentModalViewController
on it, otherwise there is no View
hierarchy the compiler can comply with.
Upvotes: 0