You need to create a window yourself if you do not use the option of the main interface:
window = UIWindow(frame:UIScreen.mainScreen().bounds)
Swift 3.0
self.window = UIWindow(frame: UIScreen.main.bounds)
Then call your code above using window
.
Finally, call makeKeyAndVisible()
on the window.
source share