作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
打开应用内电子邮件时,是否可以默认将键盘聚焦在“收件人”字段上?如果是,那么我们如何访问电子邮件中的“收件人”字段?
任何实现目标的途径都会受到赞赏。
最佳答案
您可以使这些字段成为第一响应者。
如果您将以下方法添加到您的类中...
//Returns true if the ToAddress field was found any of the sub views and made first responder
//passing in @"MFComposeSubjectView" as the value for field makes the subject become first responder
//passing in @"MFComposeTextContentView" as the value for field makes the body become first responder
//passing in @"MFRecipientTextField" as the value for field makes the to address field become first responder
- (BOOL) setMFMailFieldAsFirstResponder:(UIView*)view mfMailField:(NSString*)field{
for (UIView *subview in view.subviews) {
NSString *className = [NSString stringWithFormat:@"%@", [subview class]];
if ([className isEqualToString:field])
{
//Found the sub view we need to set as first responder
[subview becomeFirstResponder];
return YES;
}
if ([subview.subviews count] > 0) {
if ([self setMFMailFieldAsFirstResponder:subview mfMailField:field]){
//Field was found and made first responder in a subview
return YES;
}
}
}
//field not found in this view.
return NO;
}
然后,在呈现 MFMailComposeViewController 后,将 MFMailComposeViewController 的 View 以及您想要成为第一响应者的字段传递到函数中。
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
/*Set up the mail composer*/
[self presentModalViewController:mailComposer animated:YES];
[self setMFMailFieldAsFirstResponder:mailComposer.view mfMailField:@"MFRecipientTextField"];
[mailComposer release];
已编辑..
关于iphone - 关注电子邮件中的 ToReciepient 字段 - iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8698835/
打开应用内电子邮件时,是否可以默认将键盘聚焦在“收件人”字段上?如果是,那么我们如何访问电子邮件中的“收件人”字段? 任何实现目标的途径都会受到赞赏。 最佳答案 您可以使这些字段成为第一响应者。 如果
我是一名优秀的程序员,十分优秀!