Using View Controller from storyboard programmatically in a Page View Controller
Swift 3
let sb = UIStoryboard(name: "MainStoryboard", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "vc-identifier")
If you do viewController=[[Company100ViewController alloc] init] then yes this not a controller that is associated to a storyboard or an XIB. To load the controller with an XIB you have to do the following:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
Company100ViewController * vc = (Company100ViewController *)[sb instantiateViewControllerWithIdentifier:@"vc-identifier"];
In the storyboard make sure you set the view controller's id to vc-identifier; whatever identifier you choose.
Swift
In case you want to init from a UIViewController
object.
guard let vc = storyboard?.instantiateViewController(withIdentifier: "nameVC") else {
return
}
// add to current view
view.addSubview(vc.view)