Have been struggling with this for a while, and can never seem to get a direct answer.
Any help is appreciated!
The easiest way to switch between screens in iOS is. Add a button on the current screen. Then press control and drag the button to the target screen.
Open mainstoryboard, select the view that you want start first, then open Utilities--> Attributes. Below the "View Controller" you see the "Is initial View Controller" radio button. Just select it.
If you're in a Navigation Controller:
ViewController *viewController = [[ViewController alloc] init]; [self.navigationController pushViewController:viewController animated:YES];
or if you just want to present a new view:
ViewController *viewController = [[ViewController alloc] init]; [self presentViewController:viewController animated:YES completion:nil];
If you want to present a new view in the same storyboard,
In CurrentViewController.m,
#import "YourViewController.h" UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; YourViewController *viewController = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerIdentifier"]; [self presentViewController:viewController animated:YES completion:nil];
To set identifier to a view controller, Open MainStoryBoard.storyboard. Select YourViewController View-> Utilities -> ShowIdentityInspector. There you can specify the identifier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With