MFMessageComposeViewController 自动关闭
在我的应用程序中,我向用户呈现 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您将 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.
正如 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.