开发者

MFMailComposeViewController attachment choice

开发者 https://www.devze.com 2023-01-15 05:43 出处:网络
I\'m using a MFMailComposeViewController in my iphone app and I\'d like to give the user the choice to attach some pictures to the e-mail.

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

As there is no specific button by default, I was thinking about subclassing MFMailComposeViewController and 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.

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.

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?


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.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消