什么时候[MFMailComposeViewController canSendMail]会返回NO [英] When will [MFMailComposeViewController canSendMail] return NO

查看:762
本文介绍了什么时候[MFMailComposeViewController canSendMail]会返回NO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序正在使用MFMailComposeViewController类发送带有附件的应用内电子邮件。
如果类MFMailComposeViewController的canSendMail方法返回true(YES),则应用程序将仅尝试显示邮件编辑器对话框。具体来说,如果以下方法返回YES,则显示邮件编辑器,否则会向用户显示错误警告对话框,指出设备上没有设置电子邮件帐户:

My iPhone app is using the MFMailComposeViewController class to send an in-app email with an attachment. The app will only attempt to display the mail composer dialog if the "canSendMail" method of class MFMailComposeViewController returns true (YES). Specifically, if the following method returns YES, it shows the mail composer, otherwise the user is presented with an error alert dialog stating that there are no email accounts set up on the device:

- (BOOL)canDeviceSendEmail
{
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    return mailClass != nil && [mailClass canSendMail];
}

一组测试人员报告他们收到此错误警告对话框,即使电子邮件帐户已在设备上设置。测试人员使用iPhone 3G和OS 3.1.3。因此,MFMailComposeViewController类必须已存在,并且canSendMail方法必须返回NO。

A team of testers have reported that they get this error alert dialog, even when email accounts are set up on the device. The tester used an iPhone 3G with OS 3.1.3. Therefore the MFMailComposeViewController class must have existed, and the "canSendMail" method must have returned NO.

因此,我的问题是:除了没有设置电子邮件帐户的情况在设备上,在其他情况下canSendMail方法可以返回NO?

My question is therefore: apart from the case when there are no email accounts set up on the device, in what other circumstances can the "canSendMail" method return NO?

〜谢谢

推荐答案

如果设备上至少启用了一个电子邮件帐户,则以下呼叫应返回YES:

If at least one email account is enabled on the device, the following call should return YES:

[MFMailComposeViewController canSendMail]

相反,如果所有帐户都被禁用/删除,它将返回NO 。

Conversely, if all accounts are disabled/removed, it will return NO.

这篇关于什么时候[MFMailComposeViewController canSendMail]会返回NO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆