dekatotoro / SlideMenuControllerSwift

iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
MIT License
3.4k stars 755 forks source link

Presenting view controllers on detached view controllers is discouraged #265

Closed kamirana4 closed 7 years ago

kamirana4 commented 7 years ago

I have UINavigationController as initial view controller which contains LoginViewController. After login, i am adding the SlideMenuController from the LoginViewController and after present completion i am setting the SlideMenuController as the rootviewcontroller. Code below,

self.navigationController?.present(slideMenuController, animated: true, completion: {
            appDelegate.window?.rootViewController = slideMenuController
        })

The issue i am facing is if i add UIAlertController in the mainViewController of SlideMenuController, it gives this error,

Presenting view controllers on detached view controllers is discouraged <SlideMenuControllerSwift.ExSlideMenuController: 0x100c160c0>.

I also tried the following to check if it fixes the issue but got the same issue,

self.present(slideMenuController, animated: true, completion: {
            appDelegate.window?.rootViewController = slideMenuController
        })

The workaround i found is, if i set the SlideMenuController as rootviewcontroller without animating like below,

appDelegate.window?.rootViewController = slideMenuController

But i want the animation effect and i also don't want to use the view's -CAAnimation for now. I want a better fix for this.

I changed the SlideMenu example project by adding one extra ViewController to produce the issue. Example project can be downloaded from the following path.

(https://www.dropbox.com/s/6fwe6z0swy1gxso/SlideMenuControllerSwift-master.zip?dl=0)

kamirana4 commented 7 years ago

The issue was about wrong presentation of the slide menu controller.