简体   繁体   中英

iOS 8 app crash when is tapped sent email

i want to sent email from my app but problem is there when I tapped send button app crash and i don't know where is the problem because I used this code in previous app.

    -(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];
    }
}

Here is a Error Report. Please help

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) 

I was getting exactly the same behaviour.

I solved it by removing UIColor colorWithPatternImage: code from my App Delegate.

Stopped the app from crashing, hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM