崩溃在MFMailComposeViewController的iPad [英] Crash On MFMailComposeViewController For iPad

查看:144
本文介绍了崩溃在MFMailComposeViewController的iPad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (void) mailshareClick:(UIButton *)sender
{
    NSString  *_message = @"wait for set up Mail";
    [self waitForWhile:_message];
    if ([MFMailComposeViewController canSendMail]){
        [NSThread detachNewThreadSelector:@selector(mailFunction) toTarget:self withObject:nil];
    }
    else {
        _message = @"Please set Mail account";
        [self remove:_message];
    }
}
- (void) mailFunction
{
    NSData *data = nil;
    if ([self.files.imageArr count]>0) 
    {
        XXImage *single = [self.files.imageArr objectAtIndex:0];
        UIImage *image = [[SDImageCache sharedImageCache] imageFromKey:[[single.imagearray objectAtIndex:0] columnImage]];
        data = [UIImageJPEGRepresentation(image, 1.0f) retain];
    }
    [self performSelectorOnMainThread:@selector(mailFinished:) withObject:data waitUntilDone:YES];    
    [data release];
}
- (void) mailFinished:(NSData *)_data
{
    if ([MFMailComposeViewController canSendMail]){
        NSData *data = [_data retain];
        MFMailComposeViewController   *message = [[MFMailComposeViewController alloc] init];
        //Title
        [message setSubject:self.files.title];
        //Body
        [message setMessageBody:@"111" isHTML:YES];

        [message setToRecipients:[NSArray arrayWithObject:@"mail"]];
        //Content
        if (data != nil) {
            NSString *picStr = [[NSString alloc] initWithFormat:@"%@%@",OutsideWebsite_Normal,self.files.middlePicPath];
            [message addAttachmentData: data mimeType: @"" fileName:picStr];
            [picStr release];
            [data release];
        }
        message.mailComposeDelegate = self;
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            message.modalPresentationStyle = UIModalPresentationFormSheet;
        }
        [self presentModalViewController:message animated:YES];

        [self remove:@"Set up Ok"];
        [message release];
    }
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result) {
        case MFMailComposeResultSent:
        {
            NSLog(@"MFMailComposeResultSent");
            break;
        }
        case MFMailComposeResultSaved:
        {
            NSLog(@"MFMailComposeResultSaved");
            break;
        }
        case MFMailComposeResultFailed:
        {
            NSLog(@"MFMailComposeResultFailed");
            break;
        }
        case MFMailComposeResultCancelled:
        {
            NSLog(@"MFMailComposeResultCancelled");
            break;
        }
        default:
            break;
    }
    [self performSelector:@selector(delayDismissModalView) withObject:nil afterDelay:1];
}
-(void)delayDismissModalView
{
    [self dismissModalViewControllerAnimated:YES];
}

在调用几次电子邮件方式后,将有

After invoke a few times the email method , there will be


  • [MFSearchResultsViewController hash]:发送到解除分配的实例的消息

  • [MFSearchResultsViewController hash]: message sent to deallocated instance Or

[MFMailComposeViewController hash]:发送到解除分配的实例的消息

[MFMailComposeViewController hash]: message sent to deallocated instance

崩溃

正如你所想的那样,什么是MFSearchResultsViewController功能。

As you think of that, what is the MFSearchResultsViewController function.

无论是否可以解决问题,请给我一个帮助。 p>

Whether it can solve the problem,please give me a hand.

推荐答案

你必须为邮件控制器设置Delegate。如果将委托设置为self,请确保self具有< MFMailComposeViewControllerDelegate> 。如果所有这些都不能使其工作,请确保您没有调用 presentModalViewController 两次。

You have to setDelegate for the mail controller. If you set the delegate to "self", make sure that the "self" has <MFMailComposeViewControllerDelegate>. If all these can't make it work, make sure you didn't call presentModalViewController twice.

这篇关于崩溃在MFMailComposeViewController的iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆