1

I have an app that mostly only uses portrait mode. However, when it presents MFMailComposeViewController and MFMessageComposeViewController it is able to rotate to landscape. This has worked fine until iOS 8 where they still rotate, but their bounds seem to follow the wrong orientation.

I have the app in portrait mode and present one of those controllers. When I rotate phone into landscape I get the following result:

MFMailComposeViewController:

enter image description here

MFMessageComposeViewController:

enter image description here

EDIT: Here is the code for presenting the composers:

MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;
[mailComposeViewController setSubject:subject];
[mailComposeViewController setMessageBody:body isHTML:NO];

[self presentViewController:mailComposeViewController animated:YES completion:^{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}];

EDIT: If I inspect the views in the View Debugger I can see that although the UIWindow has rotated to landscape none of the underlaying views have. This includes UITransitionView and UILayoutContainerView.

pajevic
  • 4,607
  • 4
  • 39
  • 73
  • I'm assuming your creating an exemption in AppDelegate? Can you show that code – soulshined Feb 24 '15 at 17:27
  • Are you thinking about the ` application:supportedInterfaceOrientationsForWindow:` method? We are not using this. In stead we allow portrait and landscape in the plist and then use `shouldAutorotate` and `supportedInterfaceOrientations` in our view controllers. – pajevic Feb 25 '15 at 10:22
  • Please add a demo project – Léo Natan Feb 27 '15 at 09:09
  • Leo, I have tried replicating this behaviour in another app but I couldn't, so a demo project will probably not do any good. The app that is having this issue is very large and was developed by another team. So I guess I am mostly looking for suggestions on what could possibly cause this kind of behaviour. – pajevic Feb 27 '15 at 13:35
  • How are you presenting the model? Could you add the presentation code? – Zigglzworth Mar 01 '15 at 21:17
  • Zigglzworth: I have added the code in the question now. – pajevic Mar 02 '15 at 08:18
  • @NobleK That code does not reproduce the issue in a new project. You need to provide enough code that the issue is reproduced. – Aaron Brager Mar 02 '15 at 08:31
  • Aaron: Sadly, I am aware of this as I have stated in a comment above. This is a very large project with hundreds of classes (none written by me) and I am struggling to figure out why this problem is occurring. Obviously the presenting code was one of the first places I looked. I am mostly hoping that perhaps someone else has encountered this issue and can point me in the right direction. – pajevic Mar 02 '15 at 08:35
  • Subclass the MFMailComposerViewController.. and the orientation methods... hope that helps – Haroon Mar 02 '15 at 12:42
  • Haroon, I don't see how that would help me. To be clear, I do want them to be able to rotate. I just don't want them to be messed up like this. – pajevic Mar 02 '15 at 16:23
  • I have updated the question again with observations from the View Debugger. – pajevic Mar 03 '15 at 15:45

3 Answers3

0

This is not an solution but am sharing my experience. I've also build an app which is following only Portrait orientation. But when i try to open MFMailComposeViewController and MFMessageComposeViewController in any device orientation, it is coming in Portrait only.

I checked this only when i saw your issue. I am presenting them the same way you are doing. I am sharing Target settings and .plist entry i've used. Please see if any of them is helpful.

Target General Settings

.plist Entry

Rinto Rapheal
  • 142
  • 1
  • 10
  • Rinto, your app is behaving like expected. You have only Portrait in your target settings and that will include `MFMailComposeViewController`. I on the other hand have Portrait, Landscape Right and Landscape Left, so my `MFMailComposeViewController` will be able to rotate to landscape, which it does. It's just that it's messed up. – pajevic Mar 06 '15 at 08:53
  • Okay. Between there is some orientation change that came with iOS 8. U can check the same in this link. [link](http://stackoverflow.com/questions/26523799/is-this-an-ios-8-bug-orientation-issue-on-rotation/27540586?) I don't think there is something to do with this particular issue. Still throwing some light. – Rinto Rapheal Mar 06 '15 at 09:05
0

There are some issues with iOS8 related to rotation not working properly. Worth checking this first. Its a simple one line edit in the app delegate.

UISplitViewController rotation iOS8 not working as expected

Community
  • 1
  • 1
Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28
  • Rory, I suspected something like this myself, but I have checked and there doesn't seem to be any code like this in the project. – pajevic Mar 06 '15 at 09:00
  • If the project was created by hand or created by a recent xcode then the line may not exist. It seems to have been created by xcode 5 or earlier I think, but it never removes it. Is there any other code in there which creates a UIWindow? If the storyboard has an initial controller set I believe that code is not required and it is the UIWindow creation in that function which was causing rotation issues: Hardware rotates but the window does not so you see portrait in landscape. – Rory McKinnel Mar 06 '15 at 09:03
-1

Methods such as willRotateToInterfaceOrientation:duration: and didRotateToInterfaceOrientation: are now deprecated in iOS 8 and replaced by viewWillTransitionToSize:withTransitionCoordinator:. Depending on how you're handling rotations in your app, you may have to make changes in your code to adapt to the new methods.

Pradeep Mittal
  • 595
  • 1
  • 8
  • 19
  • We are not using these methods at all. Also, I believe this would only affect our own view controllers and nok `MFMailComposeViewController`. – pajevic Mar 05 '15 at 11:16