-1
我想在我的應用程序中呈現MFMailComposeViewController以從我的應用程序發送郵件。每當我調用該方法來呈現郵件撰寫我的應用程序崩潰,下面崩潰日誌:嘗試呈現MFMailComposeViewController時應用程序崩潰
Assertion failure in -[UICGColor encodeWithCoder:], /SourceCache/UIKit/UIKit-2372/UIColor.m:1191
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only support RGBA or the White color space, this method is a hack.'
First throw call stack:
(0x391e63e7 0x36719963 0x391e629d 0x33da07b3 0x337d6c5f 0x33d435c7 0x33d42e71 0x339099cb 0x33908d1b 0x391e3757 0x33908a95 0x339e664d 0x33974e83 0x33974d17 0x3927a80f 0x33974c0b 0x3397e261 0x3927858b 0x3397e23b 0x39277793 0x3927ab3b 0x3927867d 0x3927b613 0x3927b7d9 0x3a2397f1 0x3a239684)
libc++abi.dylib: terminate called throwing an exception
下面是我使用的代碼:
// Send email
- (void) emailAction
{
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"FavePlates app"];
UIImage *ImageToShare = selectedDishImageView.image;
NSData *myData = UIImagePNGRepresentation(ImageToShare);
[controller addAttachmentData:myData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",ImageToShare]];
NSString * msgBody = [NSString stringWithFormat:@"%@", Check Out];
[controller setMessageBody:msgBody
isHTML:NO];
if (controller) {
[self presentModalViewController:controller
animated:YES];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
NSString *messageBody= [[NSString alloc] init];
switch (result)
{
case MFMailComposeResultCancelled:
DLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
[self dismissViewControllerAnimated:YES
completion:nil];
messageBody = @"You cancelled sending message";
break;
case MFMailComposeResultSaved:
DLog(@"Mail saved: you saved the email message in the drafts folder.");
[self dismissViewControllerAnimated:YES
completion:nil];
messageBody = @"Mail saved: you saved the email message in the drafts folder'";
break;
case MFMailComposeResultSent:
DLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
[self dismissViewControllerAnimated:YES
completion:nil];
messageBody = @"Mail has been sent";
[self mailSent];
break;
case MFMailComposeResultFailed:
DLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
[self dismissViewControllerAnimated:YES
completion:nil];
messageBody = @"Email sending failed";
break;
default:
DLog(@"Mail not sent.");
[self dismissViewControllerAnimated:YES
completion:nil];
break;
}
}
u能共享代碼...? –
您是否錯誤地複製並粘貼了此內容,您在關閉之前缺少關閉「關閉」 NSString * msgBody = [NSString stringWithFormat:@「%@,Check Out]; – CW0007007
您是否在代碼中的任何位置使用ColorWithPatternImage? – GenieWanted