سؤال

Got a issue with my UIVewController and rotation which I could do with some help with.

Basically, I have a view which can rotate from portrait to landscape. When it rotates to landscape, I present a different view (a chart) to my portrait one...which is an input view, based on a UITableView. This all works fine.

Now, my portrait view (and only my portrait view) also has an 'Email' button which when pressed, creates and presents the MFMailComposeViewController so the user can email some data.

This works ok but if the user rotates the iphone to landscape whilst on the MFMailComposeViewController view, my underlying view gets no notification of the rotation so I know to change the underlying view to the chart view. So, when the user dismisses the mail view whilst still in landscape, I get my original 'portrait' input view in landscape which is out of position and incorrectly displayed.

So, is there anyway I can get notifications of rotation in my original portrait ViewController when the MFMailComposeViewController is displaying so I can make underlying changes when the original view re-appears? Or, can I prevent the underlying view from rotating when the MFMailComposeViewController is rotated?

Hope that makes sense and thanks for advice.

هل كانت مفيدة؟

المحلول

Try implementing -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation in your parent ViewController and set it to UIInterfaceOrientationPortrait.

You can also view what your MFMailComposeViewController is doing, but I think you'd have to subclass it and implement -(void)didRotateFromInterfaceOrientation: and then send info back via notifications or a delegate...but you shouldn't need to with preferredInterfaceOrientationForPresentation.

Hope this helps!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top