Ios MFMailComposer ViewController对象未在iPad中分配,但在模拟器中工作正常
当IIos MFMailComposer ViewController对象未在iPad中分配,但在模拟器中工作正常,ios,objective-c,email,mfmailcomposer,Ios,Objective C,Email,Mfmailcomposer,当Ialloc/initMFMailComposerViewController未分配时,对象为nil。应用程序在显示mailViewController时崩溃。这是我的密码: MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Photos"]; NSString
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];
MFMailComposeViewController*picker=[[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate=self;
[picker setSubject:@“照片”];
NSString*body=[NSString stringWithFormat:@]
""
""
""
""
""
"%@"
""
“”,[NSString stringWithFormat:@“来自%@”的图片,应用程序名称]];
[picker setMessageBody:body isHTML:YES];
NSData*data=UIImagePNGRepresentation(self.sharedImage);
[picker addAttachmentData:data mimeType:@“image/png”文件名:APP_NAME];
[自我呈现视图控制器:选择器已设置动画:是完成:无];
第1步:我认为首先需要从设备设置中添加帐户。如果您没有从设置中添加帐户,则您将收到此类问题
第2步:属性并合成MFMailComposeView控件对象您是否正在调用
canSendMail
以确定是否可以发送电子邮件?不,我没有调用canSendMail方法