MFMailComposer无法在io6横向模式下工作

时间:2012-11-22 10:34:10

标签: iphone objective-c ios ios6

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];

}

它在ios5中工作正常但不能在设备上进行ios6 m测试

2 个答案:

答案 0 :(得分:0)

在appdelegate中的didfinishloading中尝试以下代码

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是一个uiviewcontroller实例

答案 1 :(得分:0)

我用这种方式解决了完全相同的问题:

我做了导入:

#import <MessageUI/MFMailComposeViewController.h>

但我忘记了这一点:

#import <MessageUI/MessageUI.h>

添加了MessageUI.h的导入后,iOS 6上没有更多问题。