Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically accessing the launch screen XIB or storyboard

Tags:

ios

ios8

How can an app access the XIB or storyboard used for its launch screen? The XIB is not in the main bundle (ex: NSBundle.mainBundle().pathsForResourcesOfType(nil, inDirectory: "")). This is especially unexpected since "Launch Screen.xib" is listed in the "Copy Bundle Resources" build phase but doesn't show ip in the bundle, so Xcode must be treating it specially.

like image 492
ide Avatar asked Sep 22 '14 04:09

ide


1 Answers

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)
}
like image 58
Irfanlone Avatar answered Nov 15 '22 19:11

Irfanlone