在iOS5中dismissModalViewControllerAnimated时MFMailComposeViewController崩溃 [英] MFMailComposeViewController crashing while dismissModalViewControllerAnimated in iOS5

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

问题描述

我在我的conde中使用MFMailComposeViewController来提供邮件功能,但在发送邮件后或当我想取消邮件时它会崩溃。

I am using MFMailComposeViewController in my conde to provide Mail functionality but after sending mail or when i want to cancel mail it will be crashing.

下面是我的代码:

(IBAction)FnForPlutoSupportEmailButtonPressed:(id)sender {
{
    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

        mailer.mailComposeDelegate = self;

        [mailer setSubject:@"Need help from Pluto support team"];

        NSArray *toRecipients = [NSArray arrayWithObjects:@"support@myplu.to",nil];
        [mailer setToRecipients:toRecipients];


        NSString *emailBody = @"";

        [mailer setMessageBody:emailBody isHTML:NO];

        //mailer.modalPresentationStyle = UIModalPresentationPageSheet;

        [self presentModalViewController:mailer animated:YES];

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

    (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated with the interface    
switch (result)
    {       case MFMailComposeResultCancelled:
                        break;
                    case MFMailComposeResultSaved:
                        break;
                    case MFMailComposeResultSent:
                        break;
                    case MFMailComposeResultFailed:
                        break;
                    default:
                        break;
    } 
    [self dismissModalViewControllerAnimated:YES];
     }

我已阅读所有博客帖子但未找到解决方案,这篇博客文章对此有很好的解释但是根据这个,我没有在viewdidload或viewdidappear中呈现我的视图控制器。

I have read all blog post but no solution is found, This blog post is having good explaination about this but as per this i am not presenting my view controller in viewdidload or viewdidappear.

我正在获取EXE_BAD_ACCESS,以下是崩溃日志:

I'm Getting EXE_BAD_ACCESS, Following is the crash log :

**

> #0  0x00000000 in ?? ()
> #1  0x01dc5aa4 in -[UIViewController _setViewAppearState:isAnimating:] ()
> #2  0x01dc5f47 in -[UIViewController __viewDidDisappear:] ()
> #3  0x01dc6039 in -[UIViewController _endAppearanceTransition:] ()
> #4  0x01dd2e7e in -[UIViewController(UIContainerViewControllerProtectedMethods) endAppearanceTransition] ()
> #5  0x01fc8de1 in -[UIWindowController transitionViewDidComplete:fromView:toView:] ()
> #6  0x01da334b in -[UITransitionView notifyDidCompleteTransition:] ()
> #7  0x01da3070 in -[UITransitionView _didCompleteTransition:] ()
> #8  0x01da531b in -[UITransitionView _transitionDidStop:finished:] ()
> #9  0x01d23fb6 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] ()
> #10 0x01d24154 in -[UIViewAnimationState animationDidStop:finished:] ()
> #11 0x0163bbce in CA::Layer::run_animation_callbacks ()
> #12 0x03664fe4 in _dispatch_client_callout ()
> #13 0x03655997 in _dispatch_main_queue_callback_4CF ()
> #14 0x012c03b5 in __CFRunLoopRun ()
> #15 0x012bf804 in CFRunLoopRunSpecific ()
> #16 0x012bf6db in CFRunLoopRunInMode ()
> #17 0x030f1913 in GSEventRunModal ()
> #18 0x030f1798 in GSEventRun ()
> #19 0x01ce82c1 in UIApplicationMain ()

**

根据Apple for ios 5的更新文档,他们提到:

As per updated document of apple for ios 5 they mentioned :

presentModalViewController:animated:

presentModalViewController:animated:

Presents由给定视图控制器管理给用户的模态视图。 (已弃用。请改用 presentViewController:animated:completion:。)

Presents a modal view managed by the given view controller to the user. (Deprecated. Use presentViewController:animated:completion: instead.)

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
Parameters

解散接收器提供的视图控制器。 (已弃用。请改用 dismissViewControllerAnimated:completion:。)

Dismisses the view controller that was presented by the receiver. (Deprecated. Use dismissViewControllerAnimated:completion: instead.)

- (void)dismissModalViewControllerAnimated:(BOOL)animated

我也试过这个但它仍然崩溃

I had tried this also but it still crashes

推荐答案

如果您的代码中实现了sharekit框架,请转到SHK.m并更改

If your are having sharekit framework implemented in your code goto SHK.m and change

        [[currentView parentViewController] dismissModalViewControllerAnimated:YES];

        [currentView  dismissModalViewControllerAnimated:YES];

这将解决您的问题。

感谢大家的回复。

并评论这些行

SHKSwizzle([MFMailComposeViewController class], @selector(viewDidDisappear:), @selector(SHKviewDidDisappear:));
if (NSClassFromString(@"MFMessageComposeViewController") != nil) SHKSwizzle([MFMessageComposeViewController class], @selector(viewDidDisappear:), @selector(SHKviewDidDisappear:));

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

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