Programmatically accessing the launch screen XIB or storyboard
If LaunchScreen is storyboard
and not a xib
, Use the following code.
let launchScreen = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()
if let launchView = launchScreen?.view {
view.addSubview(launchView)
}
As Xib is not in the main bundle getting path returns nil, But you can get the XIB of the launch screen without the help of path using method
let launchScreenNib = UINib(nibName: "LaunchScreen", bundle: nil)
or
You can load get views from XIB as
// Swift
let objects = NSBundle.mainBundle().loadNibNamed("LaunchScreen", owner: self, options: nil)
let view = objects[0] as UIView
// Obj C
NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil];
UIView *view = [objects objectAtIndex:0];