MFMailComposeViewController 默认为只读模式
我正在尝试在我正在构建的 iPhone 应用程序中使用 MFMailComposeViewController,但我无法让它正常工作。我正在遵循Apple的示例代码MailComposer。正如您在示例中看到的,MFMailComposeViewController 允许您输入您想要的任何消息,对于收件人,您可以输入电子邮件地址或从联系人中选择它们。我的实现与示例中完全相同,并且 MFMailComposeViewController 按预期出现和消失。然而,控制器似乎处于只读模式;即,用户不能更改任何字段。我可以在显示控制器之前以编程方式更改不同字段的值,但是一旦它可见,就无法对任何字段进行修改。我已经检查了很多次,但我找不到我的实现和苹果的实现之间有什么不同。我被难住了!以前有人遇到过这个问题吗?有什么建议吗?
非常感谢大家提供的任何帮助!
I'm trying to use the MFMailComposeViewController in an iPhone app I'm building, but I can't get it to work correctly. I was following the Apple's sample code MailComposer. As you can see in the sample, the MFMailComposeViewController lets you type in whatever message you want, and in the case of recipients you can either type the email addresses or pick them from your contacts. My implementation is exactly as in the sample, and the MFMailComposeViewController appears and disappears as expected. However, the controller seems to be in read-only mode; i.e., the user can't change any of the fields. I can change the values of the different fields programmatically before showing the controller, but once it's visible no modifications can be done to any of the fields. I have checked everything a bunch of times, but I can't find anything different between my implementation and Apple's. I'm stumped! Has anyone encountered this issue before? Any suggestions?
Thanks a lot for any help you all can provide!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现问题了!我的应用程序中的父视图控制器监听摇动手势,这要求监听摇动的视图控制器成为第一响应者。父视图控制器需要
在显示 MFMailComposeViewController 之前调用。添加该行后,MFMailComposeViewController 的工作就像一个魅力。
一般来说,任何侦听摇动手势的视图控制器都应该在显示任何其他视图控制器之前放弃第一响应者。否则,即使相应的视图控制器不可见,应用程序也会继续响应摇动手势,这肯定会导致比 MFMailComposeViewController 以奇怪的只读模式显示更糟糕的问题。
Found the problem! A parent view controller in my application listens to shake gestures, which requires that view controller listening for shakes becomes the first responder. The parent view controller needs to call
before showing the MFMailComposeViewController. After adding that line, the MFMailComposeViewController worked like a charm.
In general, any view controllers listening for shake gestures should resign first responder before showing any other view controllers. Otherwise, the app will continue to respond to shake gestures even when the corresponding view controller is not visible, which can definitely lead to even worse problems than the MFMailComposeViewController showing up in weird read-only mode.