点击发送电子邮件时 iOS 8 应用程序崩溃

标签 ios objective-c xcode

我想从我的应用程序发送电子邮件,但是当我点击发送按钮应用程序崩溃时出现问题,我不知道问题出在哪里,因为我在以前的应用程序中使用了这段代码。

    -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result) {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail Saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail Sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;

        default:
            break;
    }

    [self dismissViewControllerAnimated:YES completion:NULL];
}

-(IBAction)sentFeedback:(id)sender
{
    MFMailComposeViewController *sentFeed = [[MFMailComposeViewController alloc] init];
    [sentFeed setMailComposeDelegate:self];
    if ([MFMailComposeViewController canSendMail]) {
        [sentFeed setToRecipients:[NSArray arrayWithObjects:@"something@test.com", nil]];
        [sentFeed setSubject:@"Test Report Problem"];
        [sentFeed setMessageBody:@"" isHTML:NO];
        [sentFeed setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self presentViewController:sentFeed animated:YES completion:NULL];
    }else{
        UIAlertView *sentError = [[UIAlertView alloc] initWithTitle:@"Error" message:@"An Error has Occured" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [sentError show];
    }
}

这是一个错误报告。请帮忙

2014-11-08 15:22:39.945 AppName[13619:886435] *** Assertion failure in -[UICGColor encodeWithCoder:], /SourceCache/UIKit_Sim/UIKit-3318/UIColor.m:1448
2014-11-08 15:22:39.949 AppName[13619:886435] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001124fb3f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000112194bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001124fb25a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00000001106a928f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   UIKit                               0x0000000111115aba -[UIColor encodeWithCoder:] + 972
    5   Foundation                          0x0000000110656ba5 _encodeObject + 1120
    6   Foundation                          0x0000000110656409 +[NSKeyedArchiver archivedDataWithRootObject:] + 162
    7   UIKit                               0x00000001114391f8 -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:selectorString:forRemoteProcess:] + 2828
    8   UIKit                               0x0000000111434274 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke + 872
    9   CoreFoundation                      0x000000011243cce6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
    10  CoreFoundation                      0x000000011243cbec -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    11  UIKit                               0x0000000111433efa +[_UIAppearance _recordersExcludingSource:withWindow:] + 137
    12  UIKit                               0x00000001115edeea UIViewServiceCurrentAppearanceSerializedRepresentations + 77
    13  UIKit                               0x00000001114efdd9 +[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:] + 232
    14  UIKit                               0x00000001114efc2e +[_UIRemoteViewController requestViewController:fromServiceWithBundleIdentifier:connectionHandler:] + 94
    15  MessageUI                           0x000000010f2f0171 -[MFMailComposeInternalViewController initWithNibName:bundle:] + 129
    16  MessageUI                           0x000000010f2c1866 -[MFMailComposeViewController initWithURL:] + 198
    17  AppName                            0x000000010ef40aef -[ProfileScreenViewController sentFeedback:] + 79
    18  UIKit                               0x0000000110ef19ee -[UIApplication sendAction:to:from:forEvent:] + 75
    19  UIKit                               0x0000000110ff7bd0 -[UIControl _sendActionsForEvents:withEvent:] + 467
    20  UIKit                               0x0000000110ff6f9f -[UIControl touchesEnded:withEvent:] + 522
    21  UIKit                               0x0000000110f373b8 -[UIWindow _sendTouchesForEvent:] + 735
    22  UIKit                               0x0000000110f37ce3 -[UIWindow sendEvent:] + 683
    23  UIKit                               0x0000000110f04ae1 -[UIApplication sendEvent:] + 246
    24  UIKit                               0x0000000110f11bad _UIApplicationHandleEventFromQueueEvent + 17370
    25  UIKit                               0x0000000110eed233 _UIApplicationHandleEventQueue + 1961
    26  CoreFoundation                      0x0000000112430ad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    27  CoreFoundation                      0x000000011242699d __CFRunLoopDoSources0 + 269
    28  CoreFoundation                      0x0000000112425fd4 __CFRunLoopRun + 868
    29  CoreFoundation                      0x0000000112425a06 CFRunLoopRunSpecific + 470
    30  GraphicsServices                    0x000000011364f9f0 GSEventRunModal + 161
    31  UIKit                               0x0000000110ef0550 UIApplicationMain + 1282
    32  AppName                             0x000000010ef410c3 main + 115
    33  libdyld.dylib                       0x00000001174aa145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

最佳答案

我得到了完全相同的行为。

我通过从我的应用程序委托(delegate)中删除 UIColor colorWithPatternImage: 代码解决了这个问题。

阻止了应用程序崩溃,希望有帮助

关于点击发送电子邮件时 iOS 8 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26818024/

相关文章:

ios - 不可重现的 webcore 崩溃

objective-c - NSString的高效字符处理

ios - 我试图在滚动页面时更改 ImageView 高度

iphone - 如何在 xcode 中打印或查看方法调用堆栈?

iphone - 如何将 NSString 中的所有字母大写?

ios - 使用Parse是否比设置自己的身份验证更好?

iphone - 如何使用 GET 方法 JSON Objective C 在 NSRequestURL 中传递特殊字符(如 #、@、%、$)

ios - 在Safari iOS上-播放YouTube视频HTML5播放器会打开并自动关闭

ios - Objective-C 的调用图或控制流图(iOS 应用程序)

xcode - 如何将 Xcode 与克隆的 git 存储库一起使用