Vlad Z.
Vlad Z.

Reputation: 3451

disable landscape mode in mailViewController

I disabled landscape mode with following code in my app. :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);


}

But when mail view shows it somehow enables land landscape mode.

code of mail action:

if ([MFMailComposeViewController canSendMail])
            {
                MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
                mailer.mailComposeDelegate = self;
                [mailer setSubject:@"Subject 1"];
                UIImage *myImage = [UIImage imageNamed:@"logo_v22.png"];
                NSData *imageData = UIImagePNGRepresentation(myImage);
                [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"];
                NSString *emailBody = @"Test ";
                [mailer setMessageBody:emailBody isHTML:NO];

                [self presentModalViewController:mailer animated:YES];


            }

Main question: how to disable landscape mode in mailView?


Additional question: how to change color of buttons in mailView? (Cancel button and send button)

Upvotes: 0

Views: 299

Answers (1)

Madivad
Madivad

Reputation: 3337

What you need to do is subclass the MFMailViewController and override it's orientation. There is a good example here: MFMailComposeViewController in landscape you'll just have to change it to suit your desired orientation.

edit: It's basically because the view controller has this mode enabled by default, it is not derived from your main view controller, hence the need to subclass it

Upvotes: 1

Related Questions