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

点击发送电子邮件时iOS 8应用程序崩溃,ios,objective-c,xcode,Ios,Objective C,Xcode,我想从我的应用程序发送电子邮件,但当我点击发送按钮应用程序崩溃时问题就出现了,我不知道问题出在哪里,因为我在以前的应用程序中使用了此代码 -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { switch (result) { cas

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

    -(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) 

我得到了完全相同的行为

我通过从我的应用程序代理中删除
uicolorWithPatternImage:
code解决了这个问题


已停止应用程序崩溃,希望有帮助

能否将堆栈跟踪添加到问题中?您必须为mail composer保留一个强有力的参考。这个问题在这里搜索了很多次。我刚刚给这个问题添加了错误报告大卫,你应该把你的评论(强烈引用MFMailComposeViewController REQUIRED)作为一个答案发布,这样OP就可以接受了。那么我应该改什么呢?