0

我想在用户按下发送邮件按钮后保存用户写的邮件地址。但即使它可以设置为收件人,我也不知道如何从中读取(没有任何属性,或者更好的是任何启用读取的属性,与 toRecipient 相关)。有什么建议么?

4

2 回答 2

0

我找到了一个方法:

Code

MFMailComposeViewController *mViewController = [[MFMailComposeViewController alloc] init];

NSArray* listVues = [mViewController childViewControllers];
MFMailComposeViewController* mailContainer = [listVues objectAtIndex:0];
UIView* mailView = [[[mailContainer view] subviews] objectAtIndex:0];
UIScrollView* composer = [[mailView subviews] objectAtIndex:0];
UIView* composerFields = [[composer subviews] objectAtIndex:0];

for (UIView* item in [composerFields subviews])
{
    NSString* desc = [item description];
    if ([desc hasPrefix:@"<MFMailComposeRecipientView"] == YES)
    {
          for (UIView* subitem in [item subviews])
          {
                NSString* desc2 = [subitem description];
                if ([desc2 hasPrefix:@"<_MFMailRecipientTextField"] == YES)
                {
                        UITextView* txt = (UITextView*)subitem;
                }
           }
    }
    else
    if ([desc hasPrefix:@"MFComposeFromView"] == YES)
    {
                for (UIView* subitem in [item subviews])
                {
                    NSString* desc2 = [subitem description];
                    if ([desc2 hasPrefix:@"<UITextField"] == YES)
                    {
                        UITextView* txt = (UITextView*)subitem;
                    }
                }
    }
    else
    if ([desc hasPrefix:@"<MFComposeSubjectView"] == YES)
    {
          // ...
    }
    else
    if ([desc hasPrefix:@"<MFComposeMultiView"] == YES)
    {
          // ...
    }
}

根据任何需要更改四个“ if ([desc hasPrefix:@"..."] == YES) ”内容之一。您可以将 [txt text] 值保存到您自己的变量中。

于 2011-11-20T16:52:43.543 回答
0

我不认为有任何方法可以做到这一点。

于 2011-04-20T17:02:09.350 回答