2014-11-08 53 views
0

我想從我的應用程序發送電子郵件,但問題是當我點擊發送按鈕應用程序崩潰時,我不知道問題在哪裏,因爲我在以前的應用程序中使用此代碼。iOS 8應用程序崩潰時被竊聽發送電子郵件

-(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:@"[email protected]", 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) 
+0

可以爲您的堆棧跟蹤添加到 – 2014-11-08 14:21:56

+0

你必須保持很強的參考爲以郵件作曲家的問題。這個問題在這裏搜索詢問和回答很多次。 – 2014-11-08 14:24:08

+0

我只是在這個問題上添加錯誤報告 – somuchiha 2014-11-08 14:45:37

回答

1

我得到完全相同的行爲。

我通過從我的App Delegate中刪除UIColor colorWithPatternImage:代碼解決了這個問題。

停止應用程序崩潰,希望它有助於

相關問題