gpt4 book ai didi

iphone - 关注电子邮件中的 ToReciepient 字段 - iphone

转载 作者:行者123 更新时间:2023-12-03 21:04:32 25 4
gpt4 key购买 nike

打开应用内电子邮件时,是否可以默认将键盘聚焦在“收件人”字段上?如果是,那么我们如何访问电子邮件中的“收件人”字段?

任何实现目标的途径都会受到赞赏。

最佳答案

您可以使这些字段成为第一响应者。

如果您将以下方法添加到您的类中...

//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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com