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?
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.