MFMailComposeViewController canSendMail 在特定情况下不返回正确的值
我发现在创建/删除邮件帐户后,[MFMailComposeViewController canSendMail]
在从后台唤醒应用程序时返回错误的值。
在我的应用程序中,有一些功能仅在邮件可用时才相关。因此我想禁用将其与 canSendMail 检查一起使用的可能性。
一切正常,而不是以下情况: 1.删除/禁用iPhone上的邮件帐户(现在我正在使用iOS 4.2进行工作和测试) 2. 启动应用程序 - 所有内容均以正确的方式禁用。 3. 按主页按钮并打开“设置”。创建并设置邮件帐户。 4. 返回应用程序 - [MFMailComposeViewController canSendMail]
返回 NO,但已设置邮件帐户。 5. 按主页按钮,然后再次返回应用程序 - [MFMailComposeViewController canSendMail]
返回 YES,正如应该的那样。
此外,反之亦然,当我们打开应用程序,转到设置,删除邮件帐户,返回应用程序时,此行为是可重现的 - canSendMail 在删除后打开第一个应用程序时返回“是”,而在第二个应用程序中返回“否”。
我正在 ApplicationDelegate 的 - (void)applicationWillEnterForeground:(UIApplication *)application
函数中检查 [MFMailComposeViewController canSendMail]
。
在我看来, MFMailComposeViewController 存储值,并且有一些事件迫使它重新读取邮件可用性。另外,我尝试在正确的线程上添加一些等待(1-2秒),或者在邮件设置和运行我的应用程序之间运行其他应用程序 - 没有任何帮助。
您对我如何获得 canSendMail 的正确价值有什么想法吗?否则,唯一的方法就是杀死发现这个 bug 的 QA...
而且下面的代码也不起作用。
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
return [mailClass canSendMail];
}
return NO;
有什么建议吗?
I found that [MFMailComposeViewController canSendMail]
returns wrong value on application wake up from background after mail account was created/deleted.
In my application there's some functionality that is relevant only when mailing is available. Thus I want to disable possibility to use it with canSendMail checking.
All works well instead of the following scenario:
1. Delete/disable mail account on iPhone (now I'm working and test with iOS 4.2)
2. Start application - all stuff is disabled in correct way.
3. Press Home button and open Settings. Create and setup mail account.
4. Return to application - [MFMailComposeViewController canSendMail]
returns NO, but mail account was setup.
5. Press Home Button and then back to application again - [MFMailComposeViewController canSendMail]
returns YES, as should.
Also, this behavior is reproducible vise-versa, when we open application, go to settings, delete mail account, back to application - canSendMail returns YES for first application opening after deletion and NO, as should, on second one.
I'm checking [MFMailComposeViewController canSendMail]
at ApplicationDelegate's - (void)applicationWillEnterForeground:(UIApplication *)application
function.
It seems to me that MFMailComposeViewController store value and there's some event that force it to re-read mail availability. Also I tried to add some waiting (1-2 seconds) on proper thread, or run other application between mail setup and run my app - nothing helps.
Do you have any ideas on how I could get right value for canSendMail? Otherwise, the only way is to kill QA who found this bug...
Also the following code doesn't work too.
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
return [mailClass canSendMail];
}
return NO;
Any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论