2011-04-20 77 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文本]值保存到您自己的變量中。