在 MFMailComposeViewController 中设置第一响应者?
我正在使用 Apple 的 MailComposer 示例应用程序从我的应用程序中发送电子邮件(操作系统 3.0 功能)。是否可以使用 MFMailComposeViewController 将“收件人”、“主题”或“正文”字段设置为第一响应者?
换句话说,行为是:用户按下一个显示邮件视图的按钮(presentModalViewController)。显示邮件视图时,光标将放置在其中一个字段中,并且键盘将打开。
我注意到 MFMailComposeViewController 文档说:
“重要:邮件撰写界面本身不可自定义,并且您的应用程序不得对其进行修改。此外,在呈现界面后,您的应用程序不允许对电子邮件进行进一步更改用户仍然可以使用界面编辑内容,但会忽略编程更改,因此,您必须在呈现界面之前设置内容字段的值。”
但是,我不关心自定义界面 。 。我只想设置firstResponder。有什么想法吗?
I'm using Apple's MailComposer example application to send email from within my application (OS 3.0 functionality). Is it possible to set the To, Subject, or Body fields as first responder with MFMailComposeViewController?
In other words, the behavior would be: the user presses a button which presents the mail view (presentModalViewController). When the mail view is presented, the cursor is placed in one of the fields and the keyboard opens.
I notice the MFMailComposeViewController documentation says:
"Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface."
However, I don't care about customizing the interface. I just want to set that firstResponder. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使这些字段成为第一响应者。
如果您将以下方法添加到您的类中...
然后,在呈现 MFMailComposeViewController 后,将 MFMailComposeViewController 的视图以及您想要成为第一响应者的字段传递到函数中。
You are able to make these fields become the first responder.
if you add the following method to your class...
Then, after you present the MFMailComposeViewController, pass the MFMailComposeViewController's view into the function along with the field you want to become first responder.
在 iOS 6 中,无法再在任何文本字段 AFAICT 上设置第一响应者。浏览视图层次结构最终会显示一个 UIRemoteView,并且此处的子视图被混淆掉。
In iOS 6, it is no longer possible to set first responder on any of the text fields AFAICT. Navigating the view hierarchy eventually reveals a UIRemoteView and the subviews within here are obfuscated away.
您可以尝试仅在控制器本身上调用BecomeFirstResponder。如果这不起作用,您可以尝试在调试器中获取邮件撰写视图的子视图列表,直到找到熟悉的文本字段或文本视图,然后您可以专门对其进行编码以在代码中设置响应者状态,这可能看起来像这个(我不知道这是否有效,但这是一个例子):
You can try just calling becomeFirstResponder on the controller itself. If that doesn't work, you can try in the debugger getting the list of subviews of the mail compose view until you find a familiar textfield or textview which you can then code specifically to set the responder status in code, which might look something like this (i don't know if this will work but it's an example):
我喜欢简化代码并使其易于理解。
只需将以下代码放在后面即可:
[自我呈现ModalViewController:mailComposer动画:是];
I like to simplify the code and make it easy to understand.
Just put the follow code after:
[self presentModalViewController:mailComposer animated:YES];