views:

1440

answers:

2

My app is landscape based. I'd like to use MFMailComposeViewController in landscape but can't find anything to notifiy it about orientation. In landscape, MFMailComposeViewController displays only the top part of the mail compose window, coming in from the left side, when in landscape. Basically it covers half of the landscape screen. Is there a way to get the mail compose window to appear in landscape rather than portrait?

--- EDIT --- The view where I'd like to load the mail compose is derived like this:

//from first UIViewController
[self presentModalViewController:secondView animated:YES];

//from secondView (a UIViewController), I load the info view, which is where the mail compose shows
InfoController *infoController = [[InfoController alloc] initWithNibName:@"Info" bundle:[NSBundle mainBundle]];
[self.view addSubview:infoController.view];

From the above, the mail compose parent view is the third one loaded. In info.plist, I do this:

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight
A: 

I have a landscape app, and showing a MFMailComposeViewController seems to work fine...

My app has to switch to portrait mode sometimes because the UIImagePickerController doesn't work in landscape mode, so I use the following code in my view to re-set up landscape mode...

self.bounds = CGRectMake(0, 0, 480, 320);
self.center = CGPointMake(160, 240);
self.transform = CGAffineTransformMakeRotation(M_PI / 2);

the MFMailComposeViewController should pick up those values and know how to display itself.

David Maymudes
I'm using MFMailComposeViewController's delegate in a UIViewController. I have to use self.view.bounds and so on. If I set what you in the UIViewController's viewDidLoad, it will load portrait, which I don't want. If I do it right before the mail compose view is displayed, I get the same results as in the OP.
4thSpace
what kind of a view are you showing before the mail compose view? have you told the OS that you're in landscape mode, or are you doing your own drawing and just making it be sideways?
David Maymudes
Sorry for delay. I've edited the OP in response to your questions. Please have a look.
4thSpace
+3  A: 

If you present the MailViewController on a nested UIViewController, try displaying it on your main UIViewController. This fixed the problem for me. I just passed my main controller to the main controller.

Dimitris
Worked for me! Thanks!I figured out why too: the main view controller is in our cases the one handling rotation, and the only one which changes it's UIInterfaceRotation. The mail composer presents itself according to the viewcontroller's rotation
tadej5553