I've been using PresentModalViewController a lot and never had any issues. But when showing a modal controller from within any controller hosted by a UISplitViewController I get strange orientation bugs.
In my table view (which is root controller of the UISplitView), when a cell is touched, I call:
开发者_如何学CMyController oModal = new MyController();
oModal.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
oModal.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
this.PresentModalViewControll(oModal, true);
If the iPad is in Portrait, all is okay. If it is in landscape however, the modal controller fades in but its orientation is incorrect. Then, after fading in has finished, it suddenly flips 90 degrees and adjusts to correct orientation. I have overriden ShouldAutoRotateToInterfaceOrientation(), so that cannot be it.
Ideas?
René
I bumped into this and have a workaround, not a real solution. The problem is that the UIViewController you are presenting your modal controller from (in you code "this") is responding with the incorrect orientation to it's property interfaceOrientation. It happened to me and I'm not really sure why. The workaround is to add a custom getter for the property in your UIViewController ("this") like the following:
-(UIDeviceOrientation)interfaceOrientation
{
return [[UIDevice currentDevice] orientation];
}
I got the idea from this post. I believe the problem is that the View Controller is not properly embedded into the view controller hierarchy but haven't figured out how. Hope this helps.
精彩评论