2011-04-20 80 views
0

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

回答

0

我不认为有什么办法可以做到这一点。

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) 
    { 
      // ... 
    } 
} 

变化的四大中心之一, “如果([DESC hasPrefix:@” ... “] == YES)”,根据需要任意内容。 您可以将[txt文本]值保存到您自己的变量中。