2

i have add one Toast message first time is working Good , but When i use This code in appdelegate file toast message is not working Here is my code i am using in app delegate This Code "instantiateViewControllerWithIdentifier" for direct go to this page

 self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
            var storyboard = UIStoryboard(name: "Main", bundle: nil)

          //  var initialViewController = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController

             var initialViewController = storyboard.instantiateViewControllerWithIdentifier("RevelControllerNavigation") as! UIViewController

            self.window?.rootViewController = initialViewController
            self.window?.makeKeyAndVisible()

for Toast message i am using this

 UIApplication.sharedApplication().windows.first?.addSubview(self.view)

1 Answers1

0

You cant add a new UIWindow in ios environment. You have to use the one in the delegate.

UIApplication.sharedApplication().delegate?.window??.rootViewController = initialViewController
Arbitur
  • 38,684
  • 22
  • 91
  • 128