I want to save, after user press send mail button, the mail addresses an user wrote. But even if it could be set the to recipient I don't know how to read from it (there aren't any properties, or better any read enabled one, related to toRecipient). Any suggestions?
Asked
Active
Viewed 369 times
2 Answers
0
I find a way:
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)
{
// ...
}
}
Change one of the four " if ([desc hasPrefix:@"..."] == YES) " content according to any needs. You can save the [txt text] value to your own variable.

Dugh
- 171
- 1
- 3