Reputation: 77
I am trying to change views but I want have to do it through code and not through storyboard for reasons that don't really matter, and I found this code:
[[self ] presentModalViewController:[self destinationViewController] animated:NO];
the problem is I don't know what to put in for presentModalViewController or destinationViewController. Is there some way to figure out what my views are called so i can put them in?
Upvotes: 1
Views: 427
Reputation: 527
At the top you should have
#import "NameOfViewController.h"
Then later
UIViewController *destinationViewController = [[NameOfViewController alloc] init];
[self presentViewController:destinationViewController animated:NO completion:nil];
Use presentViewController
instead of presentModalViewController
as the latter method is deprecated. I hope that works for you.
Upvotes: 2
Reputation: 48524
In the example you give, [self destinationViewController]
creates and returns a UIVIewController.
You can either:
load one from a NIB file
controller = [[MyController alloc]
initWithNibName:@"nib-resource-name" bundle:nil];
load one from the storyboard
MyController * controller = [self.storyboard
instantiateViewControllerWithIdentifier:@"controller-storyboard-id"];
create one programmatically
Upvotes: 0