MFMailComposer not working in io6 landscape mode

2019-07-09 12:15发布

问题:

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController * mailComposeController=[[MFMailComposeViewController alloc]init];
    mailComposeController.mailComposeDelegate = self;
  //  mailComposeController.wantsFullScreenLayout = NO;
    [mailComposeController setSubject:@"WallPaperApp."];
    [mailComposeController setMessageBody:@"This is my new Wallpaper." isHTML:NO];
    UIImage *img=mainImageView.image;
    UIImage *img1=[UIImage imageNamed:@"aaa.jpg"];
    NSData *imageData = UIImagePNGRepresentation(img);      
    [mailComposeController addAttachmentData:imageData mimeType:@"image/jpg" fileName:[NSString stringWithFormat:@"photo.png"]];

    [self presentModalViewController:mailComposeController animated:YES];
    //[mailComposeController release];

}

its working fine in ios5 but not working in ios6 m testing on device

回答1:

Try below code in didfinishloading in appdelegate

rootController = 
    [[firstViewController alloc] 
     initWithNibName:@"firstViewController" bundle:nil];
    navigationController = [[UINavigationController alloc]initWithRootViewController:rootController];
        window = [[UIWindow alloc] 
                  initWithFrame:[[UIScreen mainScreen] bounds]];
        [window addSubview:navigationController.view];
[window makeKeyAndVisible];

rootController is a uiviewcontroller instance



回答2:

I fixed the exact same problem this way:

I did import:

#import <MessageUI/MFMailComposeViewController.h>

But I forgot this:

#import <MessageUI/MessageUI.h>

After adding the import of MessageUI.h, no more problems on iOS 6.