Communicating Two Story Board.
if we have a two storyboard eg. storyboard1 and storyboard2 then we can call their view controller from any storyboard.
example: calling view controller of storyboard2 from storyboard1.
Steps we have to follow.
1: open stroryboard2 and select view controller to call.
2: click on “show the identity inspector ” and here write their storyboard ID as “MainViewController”;
3: write code where you have to load .
if your storyboard1 contains navigation controller then no need to UI navigation controller but if you have no navigation controller as a parent then we have to push using UI navigation controller.
with navigation in your story board:
1 2 3 4 |
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"stryboard2" bundle:nil]; UIViewController *initViewController = [sb instantiateInitialViewController]; initViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentViewController:initViewController animated:YES completion:NULL]; |
without navigation in your strory board:
1 2 3 4 5 |
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"storyboard2" bundle:nil]; UIViewController *initViewController = (UIViewController *)[sb instantiateViewControllerWithIdentifier:@"MainViewController"]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:initViewController]; initViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentViewController:navigationController animated:YES completion:NULL]; |
4: and you can pass the data by allocation memory of class.
viewcontrollerclass v= [viewcontrollerclass alloc] init];
v.first_element = @”ABC”;
v.second_element = @”due”;