mailsender不在ios7中工作

时间:2014-02-10 06:15:23

标签: ios7 cocos2d-x email-integration

需要有关cocos2d-x代码中的电子邮件集成的帮助。 该代码适用于iOS 6,但不适用于iOS7 电子邮件视图已加载,但点击发送后电子邮件视图消失,无法触摸屏幕(屏幕上的元素无法触摸)。

#import "MailSender.h"
#import "../cocos2dx/platform/ios/EAGLView.h"
#import "RootViewController.h"

@implementation MailSender

- (void)openMail
{

    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

        mailer.mailComposeDelegate = self;

        [mailer setSubject:@"Check Ramp Jump game :D"];

        NSString *emailBody = [NSString stringWithFormat:@"<p>I have played the game Ramp Jump, please check it</p>"];

        [mailer setMessageBody:emailBody isHTML:YES];

        // only for iPad
        // mailer.modalPresentationStyle = UIModalPresentationPageSheet;

        UIWindow *window = [[UIApplication sharedApplication] keyWindow];
        currentModalViewController = [[UIViewController alloc] init];
        [window addSubview:currentModalViewController.view];
        [currentModalViewController presentViewController:mailer animated:YES completion:NULL];
        //[mailer release];

    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
                                                        message:@"Your device doesn't support the composer sheet"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles: nil];
        [alert show];
        [alert release];
    }

}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    const char *message;
    switch (result)
    {
        case MFMailComposeResultCancelled:
            message = "Mail cancelled";
            break;
        case MFMailComposeResultSaved:
            message = "Mail saved";
            break;
        case MFMailComposeResultSent:
            message = "Mail send";
            break;
        case MFMailComposeResultFailed:
            message = "Mail failed";
            break;
        default:
            message = "Mail cancelled";
            break;
    }
    NSLog(@"%s",message);
    UIAlertView *myalertView = [[UIAlertView alloc]initWithTitle:@"Mail"
                                                         message:[NSString stringWithCString:message encoding:NSASCIIStringEncoding] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [myalertView show];

    [currentModalViewController dismissViewControllerAnimated:YES completion:NULL];

    [currentModalViewController.view.superview removeFromSuperview];

    [currentModalViewController release];

}

@end

0 个答案:

没有答案