我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];
答案 0 :(得分:2)
步骤1:我认为首先您需要从设备设置中添加帐户。如果您尚未从设置中添加帐户,则会遇到此类问题。
步骤2:对MFMailComposeView ControllerObject进行属性化和合成