MFMailComposeViewController 的“无邮件帐户”问题警报 - SDK 3.0 与 SDK 4.0

发布于 2024-09-06 22:09:08 字数 972 浏览 9 评论 0原文

当我为不同的 Base SDK 构建这段代码时,我遇到了一个问题:

MFMailComposeViewController *mail = nil;
mail = [[MFMailComposeViewController alloc] init];
NSString *description = @"Some mail string";
if([MFMailComposeViewController canSendMail])
{
    mail.mailComposeDelegate =self;
    [mail setSubject:story.title];
    [mail setMessageBody:[NSString stringWithFormat:(NSString *)kMessageBodyFormat,description,story.webLink] isHTML:NO];
}
[self presentModalViewController:mail animated:YES];
[mail release];
mail=nil;

当我使用 Base SDK 3.0 构建它时,如果 MFMailComposeViewController 的初始化返回 nil,如果用户没有任何邮件帐户,系统默认发出“无邮件帐户”警报。

但是,当我使用 Base SDK 4.0 构建它并将其部署到 3.0 操作系统时,如果用户没有任何邮件帐户,系统不会显示相同的警报,而是 presentModalViewController 崩溃。

如果用户在 3.0 和 4.0 基础 SDK 中都没有任何邮件帐户,则 MFMailComposeViewController 的初始化将返回 nil,但在 SDK 3.0 但 SDK 4.0 的情况下,presentModalViewController 会智能地发出警报在 3.0 上部署失败并崩溃。

有没有人遇到过这个问题/有任何想法到底发生了什么。

谢谢, 拉吉

I have a problem with this piece of code when I build it for different Base SDKs:

MFMailComposeViewController *mail = nil;
mail = [[MFMailComposeViewController alloc] init];
NSString *description = @"Some mail string";
if([MFMailComposeViewController canSendMail])
{
    mail.mailComposeDelegate =self;
    [mail setSubject:story.title];
    [mail setMessageBody:[NSString stringWithFormat:(NSString *)kMessageBodyFormat,description,story.webLink] isHTML:NO];
}
[self presentModalViewController:mail animated:YES];
[mail release];
mail=nil;

When I build it with Base SDK 3.0, in case if MFMailComposeViewController's initialization returns nil which occurs if the user does not has any mail accounts, the default "No mail accounts" alert is put up by the system.

But when I build it with Base SDK 4.0 and deploy it for 3.0 OS, if user does not has any mail accounts, the same alert is not displayed by the system, instead presentModalViewController crashes.

MFMailComposeViewController's initialization returns nil if user does not has any mail accounts in both 3.0 and 4.0 base SDK, but somewhere presentModalViewController intelligently puts up the alert in case of SDK 3.0 but SDK 4.0 deployed on 3.0 fails and crashes.

Has anybody faced this problem / any ideas what actually is happening.

Thanks,
Raj

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不再让梦枯萎 2024-09-13 22:09:08

当我遇到同样的问题时,我发现了这个问题。

我认为是因为,如果手机中没有设置邮件帐户。 [[MFMailComposeViewController alloc] init] 返回 nil。

因此,在呈现视图控制器之前,我们需要检查它是否为零。

I found this question while I am having the same problem.

I think its because, if there is no mail account set up in the phone. The [[MFMailComposeViewController alloc] init] returns nil.

So before presenting the view controller, we need to check if it is nil or not.

岁月如刀 2024-09-13 22:09:08

我刚刚对 iOS 4 进行了一些 Beta 测试,并看到了你的帖子。我不明白为什么它返回零,所以感谢您的回答。至于你的问题的答案,你只需要检查它是否为零。如果它为零,则不显示模态视图控制器。它仍然会显示弹出窗口。

I was just doing some beta testing with iOS 4 and came across your post. I couldn't figure out why it was return nil, so thanks for the answer. As far as an answer to your question, you just need to check if it's nil. If it's nil then don't present the modal view controller. It will still show the popup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文