Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying MFMailComposeViewController in landscape

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
like image 843
4thSpace Avatar asked Jul 09 '09 02:07

4thSpace


2 Answers

We can add following code in Application Delegate class implementation to override auto rotation by mail composer view controller.

@interface MFMailComposeViewController (AutoRotation)
// to stop auto rotation
@end

@implementation MFMailComposeViewController (AutoRotation)
// stop auto rotation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // should support all interface orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
like image 106
Tharindu Madushanka Avatar answered Sep 28 '22 09:09

Tharindu Madushanka


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.

like image 35
Dimitris Avatar answered Sep 28 '22 08:09

Dimitris