Linux MFMailComposeViewController 附件选择

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3677117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:16:29  来源:igfitidea点击:

MFMailComposeViewController attachment choice

iphoneemailattachmentmfmailcomposeviewcontroller

提问by Jukurrpa

I'm using a MFMailComposeViewControllerin my iphone app and I'd like to give the user the choice to attach some pictures to the e-mail.

MFMailComposeViewController在我的 iphone 应用程序中使用 a ,我想让用户选择将一些图片附加到电子邮件中。

As there is no specific button by default, I was thinking about subclassing MFMailComposeViewControllerand adding a button for this. Unfortunately, according to the documentation the addAttachmentData:method shouldn't be called once the view has been displayed, so the choice can not be made during the mail composition.

由于默认情况下没有特定的按钮,我正在考虑子类化MFMailComposeViewController并为此添加一个按钮。不幸的是,根据文档,addAttachmentData:一旦显示视图就不应调用该方法,因此在邮件撰写期间无法进行选择。

I also thought about creating my own mail composer view, but according to this question: Send mail without MFMailComposeViewController, Apple does not want developers to do this as this could be used to abuse the user's mail account.

我也考虑过创建自己的邮件编辑器视图,但根据这个问题:在没有 MFMailComposeViewController 的情况下发送邮件,Apple 不希望开发人员这样做,因为这可能会被用来滥用用户的邮件帐户。

So, it seems the only solution is to ask the user prior to showing up MFMailCompose, and the only way for the user to change his choice would be to cancel mail composition and start it again, am I right?

因此,似乎唯一的解决方案是在显示 MFMailCompose 之前询问用户,而用户更改其选择的唯一方法是取消邮件撰写并重新开始,对吗?

采纳答案by Jukurrpa

Self answer: for me, the simplest way was to add a UIAlertView asking the user wether he wants to add the images or not, prior to showing up the mail composer view. This is adequate as all images should be sent together (so it's all or none), but for more elaborate cases (chose some images from the iphone for example), Anil Sivadas' answer might be a solution.

自我回答:对我来说,最简单的方法是在显示邮件编辑器视图之前添加一个 UIAlertView 询问用户他是否想要添加图像。这是足够的,因为所有图像都应该一起发送(所以要么全部发送,要么不发送),但对于更复杂的情况(例如,从 iphone 中选择一些图像),Anil Sivadas 的回答可能是一个解决方案。

回答by Anil Sivadas

When user tap the attach button, dismiss the MFMailComposeViewController and open the image picking controller. When the image is picked, create a new MFMailComposeViewController with the previous content and the new image as attachment.

当用户点击附加按钮时,关闭 MFMailComposeViewController 并打开图像拾取控制器。选择图像后,创建一个新的 MFMailComposeViewController,其中包含以前的内容和新图像作为附件。

I have not tried this. You can give a try.

我没有试过这个。你可以试试。