Reputation: 5545
I have a storyboard based project
I need to call a UIViewController class which is Xib based.
how can i call Xib class from storyboard and vice-versa?
Upvotes: 0
Views: 536
Reputation: 9589
I have 3 controllers.ViewController and ThirdViewController in Storybboard.SecondViewController is XIB part.
First I call XIB from Storyboard
ViewController.m
#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)actionGoXIB:(id)sender
{
SecondViewController *secondVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
}
Now I call Stoyboard from XIB
If you want to acheive this, first Go to Storyboard Click ThirdViewController
Click->Identity Inspector
Then Click -> Identity
Now Set the Storyboard ID to ThirdViewController in the Identity section
See the screenshots below
SeconViewController.m
#import "SecondViewController.h"
#import "ThirdViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (IBAction)actionGoStoryboard:(id)sender
{
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ThirdViewController *thirdVC = [mainStoryBoard instantiateViewControllerWithIdentifier:@"ThirdViewController"];
[self.navigationController pushViewController:thirdVC animated:YES];
// [self presentViewController:thirdVC animated:YES completion:nil];
}
Upvotes: 1