当我试图打开邮件作曲家时,花了3秒或更长时间打开作曲家

时间:2011-06-26 13:16:24

标签: objective-c mfmailcomposeviewcontroller

这是我的mailcompose发送邮件的代码。当我按下emailButton时,mailcomposer需要3秒或更长时间才能弹出。

-(void)emailButtonAction
{
    MFMailComposeViewController *controller = nil;
    controller = [[MFMailComposeViewController alloc] init];
    controller.mailComposeDelegate =self ;
    if([MFMailComposeViewController canSendMail])
    {
        NSString *emailSubj =@"";
        emailSubj = [emailSubj stringByAppendingString:@"Interesting comic to share with you"];
        [controller setSubject:emailSubj];
        cartoonImage = [self saveCartoon];
        crtImageData = UIImagePNGRepresentation(cartoonImage);
        [controller addAttachmentData:crtImageData
                             mimeType:@"image/png"
                             fileName:@"bluepal_comicbuilder_image.png"];
        [controller setMessageBody:@"I used BluePal's Comic Builder to make this comic and it is very interesting & easy to use. You can also download this application from iTunes and enjoy!" isHTML:YES];
        [self presentModalViewController:controller animated:YES];

    }
    else 
    {
        NSLog(@"no email found");
    }

    [controller release];
    controller=nil;

}


-(void)mailComposeController: (MFMailComposeViewController *)controller

         didFinishWithResult:(MFMailComposeResult)result

                       error:(NSError *)error 
{

    switch (result)
    {
            UIAlertView *alertView1;
        case MFMailComposeResultCancelled:
            break;

        case MFMailComposeResultSaved:
            alertView1=[[UIAlertView alloc]initWithTitle:@"Comic Builder" message:@"Your mail saved successfully" delegate:self cancelButtonTitle:@"Ok!" otherButtonTitles:nil];
            [alertView1 show];
            [alertView1 release];
            break;

        case MFMailComposeResultSent:
            alertView1=[[UIAlertView alloc]initWithTitle:@"Comic Builder" message:@"Your mail sent successfully" delegate:self cancelButtonTitle:@"Ok!" otherButtonTitles:nil];
            [alertView1 show];
            [alertView1 release];
            break;

        case MFMailComposeResultFailed:
            alertView1=[[UIAlertView alloc]initWithTitle:@"Comic Builder" message:@"Unable to send the mail please try again" delegate:self cancelButtonTitle:@"Ok!" otherButtonTitles:nil];
            [alertView1 show];
            [alertView1 release];
            break;

    }
        [controller dismissModalViewControllerAnimated:YES];

}

- (UIImage*)saveCartoon
{
    UIGraphicsBeginImageContext(myView.bounds.size);
    [myFirstView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *finishedCartoon = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return finishedCartoon;
}

任何人都可以建议我如何解决这个问题。

感谢所有人, Monish。

0 个答案:

没有答案