开发者

PresentModalViewController from within UISplitViewController: weird behavior in landscape mode

开发者 https://www.devze.com 2023-02-02 02:50 出处:网络
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 b

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消