当我alloc
/init
MFMailComposerViewController
时,它没有被分配,对象是nil
。应用程序在呈现mailViewController
时崩溃。这是我的代码:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Photos"];
NSString *body = [NSString stringWithFormat:@"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">"
"<html>"
"<head>"
"<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">"
"</head>"
"<body>"
"%@"
"</body>"
"</html>",[NSString stringWithFormat:@"Picture from %@",APP_NAME]];
[picker setMessageBody:body isHTML:YES];
NSData* data = UIImagePNGRepresentation(self.sharedImage);
[picker addAttachmentData:data mimeType:@"image/png" fileName:APP_NAME];
[self presentViewController:picker animated:YES completion:nil];
步骤1:我认为首先你需要从设备的设置中添加帐户。如果你还没有从设置中添加帐户,那么你会遇到这种类型的问题。
步骤2:属性化和合成您的MFMailComposeView ControllerObject