OGeek|极客世界-中国程序员成长平台

标题: ios - MFMailComposeViewController 对象未在 iPad 中分配,但在模拟器中工作正常 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:53
标题: ios - MFMailComposeViewController 对象未在 iPad 中分配,但在模拟器中工作正常

当我 alloc/init MFMailComposerViewController 时,它没有被分配,并且对象是 nil。呈现 mailViewController 时应用程序崩溃。这是我的代码:

MFMailComposeViewController  *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;

[picker setSubject"hotos"];

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"icture 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];



Best Answer-推荐答案


第 1 步:我认为首先您需要从设备的设置中添加帐户。如果您尚未从设置中添加帐户,那么您将遇到此类问题。

第 2 步:属性化和综合您的 MFMailComposeView ControllerObject

关于ios - MFMailComposeViewController 对象未在 iPad 中分配,但在模拟器中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26009365/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4