MFMessageComposeViewController 自动关闭

发布于 2024-12-20 18:24:40 字数 569 浏览 2 评论 0原文

在我的应用程序中,我向用户呈现 MFMessageViewController,10 秒后,我通过调用自动关闭它。

[self.presentedViewController performSelector:@selector(dismissModalViewControllerAnimated:) 
    withObject:[NSNumber numberWithBool:YES] afterDelay:10];

问题是,如果用户已开始使用 MFM(即通过键入或点击加号或按加号来添加收件人)编辑正文),我无法取消这个通话。我知道我可以打电话

[NSObject cancelPreviousPerformRequestsWithTarget:self.presentedViewController 
    selector:@selector(dismissModalViewControllerAnimated:) object:[NSNumber 
    numberWithBool:YES]];

,但我无法知道用户何时开始以上述方式编辑 MFM。有解决办法吗?

In my app, I present the user with an MFMessageViewController, and after 10 seconds, I auto-dismiss it by calling

[self.presentedViewController performSelector:@selector(dismissModalViewControllerAnimated:) 
    withObject:[NSNumber numberWithBool:YES] afterDelay:10];

The problem is, if the user has begun using the MFM (i.e. adding a recipient by either typing or hitting the plus sign or editing the body), I have no way to cancel this call. I know that I could call

[NSObject cancelPreviousPerformRequestsWithTarget:self.presentedViewController 
    selector:@selector(dismissModalViewControllerAnimated:) object:[NSNumber 
    numberWithBool:YES]];

but I have no way of knowing when the user has started editing the MFM in the ways described above. Is there a solution to this?

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

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

发布评论

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

评论(2

乖不如嘢 2024-12-27 18:24:40

我建议您将 MFMessageViewController 的关闭留给用户。用户已调用它&他将是何时驳回它的最佳判断者。在这种情况下,我认为自动关闭并不安全&在某些情况下可能会激怒用户。

它只是不直观。为什么你想在 10 秒后关闭?就这样吧。

一切都应该尽可能简单,但不能更简单——
阿尔伯特·爱因斯坦

I suggest that you leave the dismissal of the MFMessageViewController to the user. The user has invoked it & he would be the best judge when to dismiss it. In this case auto-dismiss I think is not safe & might piss off the user in some cases.

Its just not intuitive. Why would you want to dismiss in 10 secs? Just let it be.

Everything should be made as simple as possible, but no simpler —
Albert Einstein

旧人九事 2024-12-27 18:24:40

正如 Srikar 已经指出的那样,这可能是一个坏主意,也不是用户所期望的。

也就是说,您可以观察 UIKeyboardWillShowNotification 通知。与邮件视图控制器的任何交互都会调出键盘,因此如果用户不执行任何操作,键盘就不会显示。当然,不能保证用户实际上输入了任何内容,但我认为这是您能得到的最接近的结果。

As Srikar already pointed out, this might be a bad idea and not something a user would expect.

That said, you could observe the UIKeyboardWillShowNotification notification. Any interaction with the mail view controller would bring up the keyboard, so if the user does nothing, it wouldn't show up. Of course, there's no guarantee that the user actually typed anything, but I think this is the closest you'll get.

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