1

While presenting a view controller XCode warns me : Presenting view controllers on detached view controllers is discouraged

Why it is happening?

  • From where you are presenting viewcontroller ? this warning can comes in many different situations. share necessary code – Ketan Parmar May 16 '16 at 10:14

1 Answers1

0

It happens when you present a UIViewcontroller on viewDidLoad() because till then the view is not loaded and you are presenting a new UIViewcontroller there.

Try to present another view/UIviewcontroller after viewDidAppear() or inside if required. or just to remove warning you can use:

self.view.window?.rootViewController?.presentViewController("vc to present", animated: true, completion: nil)
ankit
  • 3,537
  • 1
  • 16
  • 32