Set First Responder in MFMailComposeViewController?

后端 未结 4 1449
南笙
南笙 2020-12-18 05:25

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 a

4条回答
  •  青春惊慌失措
    2020-12-18 06:15

    I like to simplify the code and make it easy to understand. Just put the follow code after:
    [self presentModalViewController:mailComposer animated:YES];

    for (UIView *subview in mailComposer.view.subviews) {
       NSString *className = [NSString stringWithFormat:@"%@", [subview class]];
       //NSLog(@"%@", className); // list the views - Use this to find another view
       //The view I want to set as first responder: "_MFMailRecipientTextField"
       if ([className isEqualToString:@"_MFMailRecipientTextField"]){
       [subview becomeFirstResponder];
       break; // Stop search.
      }
    }
    

提交回复
热议问题