问题
I've got a UIViewController that I'm using as a login view that's displayed modally above a UISplitViewController. Once the user has successfully logged in, the modal view is dismissed. The master view controller in the split view controller has a left bar button item to logging out. Once the logout button is tapped the login view controller is displayed modally again. If the user rotates the devices at this time, the modal login view is being dismissed.
I have no idea how to catch this. When setting a breakpoint on viewWillDissappear on the login view controller only system API's are being called - nothing I wrote.
A sample app that reproduces the problem can be found here: http://d.pr/f/c6oG
Steps to Reproduce: Launch the attached app in portrait mode. Tap the login button. Tap the master button. Tap logout. Rotate the device left or right. The modal view dismisses.
Expected Results: Launch the attached app in portrait mode. Tap the login button. Tap the master button. Tap logout. Rotate the device left or right. The modal view doesn't dismiss.
Actual Results: The modal view dismisses upon device rotation after completing the steps to reproduce above.
I've also filled a radar bug #12585564.
Any ideas? Thanks in advance!
回答1:
You need to present the login view controller from the split view controller, not the master or detail view controllers.
回答2:
Although it's not exactly what I was looking for, I ended up overriding splitViewController:shouldHideViewController:inOrientation: in the DetailViewController. After that, the issue does not happen.
I do like the look of the master view controller staying on screen when the device rotates - similar to the Settings app.
来源:https://stackoverflow.com/questions/13095686/uiviewcontroller-displayed-modally-dismisses-itself-upon-device-rotation