【问题标题】:Getting the Recepients list in MFMailComposeViewController在 MFMailComposeViewController 中获取收件人列表
【发布时间】:2012-01-24 10:21:21
【问题描述】:

我在我的应用程序中使用 MFMailcomposerViewController。一切都很好,除了我需要没有。收件人和用户发送到的收件人列表。 有关此问题的任何帮助或解决方案..

【问题讨论】:

  • 你可以得到收件人的数量但没有id的..
  • @hemant 你能给我关于如何获得编号的建议吗?收件人,我也只需要那个。提前致谢!

标签: iphone ios ios4 mfmailcomposeviewcontroller


【解决方案1】:

我没有执行此操作的标准方法,委托方法 mailComposeController:didFinishWithResult:error: 在关闭后为您提供对作曲家视图控制器的引用,但在 MFMailComposeViewController 上没有访问器可用于获取收件人数

一种解决方法是检查视图控制器的子视图,找到用于保存收件人的文本字段并获取文本:请参阅here

【讨论】:

  • 但我得到了 'aaa.aa @aa.com 和另外 3 个' 之类的字符串,在这种情况下,我无法检查电子邮件 ID 是否正确,我也需要同样的。 ...
  • 就像他在那个博客中所说的那样,我认为你只能用它来获取收件人的数量,如果他们超过了 25 个字符的限制,那么我不知道有什么方法可以告诉他们都是什么
【解决方案2】:

我终于得到了答案并想分享它...我从 [博客] 获得了很大的帮助:http://jomnius.blogspot.com/2011/02/how-to-find-mfmailcomposeviewcontroller.html

for (int x=0; x<[emailArray count]-1; x++) {
NSLog(@"%d). %@",x+1,[emailArray objectAtIndex:x]);
NSString *element = [emailArray objectAtIndex:x];
NSArray *arr = [element componentsSeparatedByString:@" & "];
if ([arr count]==1) {
    ++emailCount;
}
else{
    int more = [[[arr objectAtIndex:1] substringToIndex:1] intValue];
    emailCount+=(more+1);
}
}
 - (NSString *)findEmailAddresses:(UIView *)view depth:(NSInteger)count
{
NSString *eAddress = nil;
if (!view)
    return eAddress;
NSMutableString *tabString = [NSMutableString stringWithCapacity:count];
for (int i = 0; i < count; i++)
    [tabString appendString:@"-- "];
NSLog(@"%@%@", tabString, view);
if ([view isKindOfClass:[UITextField class]])
{
    // MAGIC: debugger shows email address(es) in first textField
    // but only if it's about max 35 characters
    if (((UITextField *)view).text)
    {
        eAddress = [NSString stringWithString:((UITextField *)view).text];
        NSLog(@"FOUND UITextField: %@", eAddress ? eAddress : @"");
        [emailArray addObject:eAddress];
    }
}
NSArray *subviews = [view subviews];
if (subviews) {
    for (UIView *view in subviews)
    {
        NSString *s = [self findEmailAddresses:view depth:count+1];
        if (s) eAddress = s;
    }
}
return eAddress;
}

【讨论】:

    【解决方案3】:

    在 iOS 6 中无法做到这一点,因为邮件组合现在是通过对远程进程 (MailCompositionService) 的 XPC 服务调用来完成的。这里有一个很好的解释:http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/。视图层次结构中的最低级别现在是与远程进程接口的 _UIRemoteView。来自http://jomnius.blogspot.com/2011/02/how-to-find-mfmailcomposeviewcontroller.html 的博文中的代码现在将始终返回 nil。

    【讨论】:

      猜你喜欢
      • 2020-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-14
      • 2016-05-21
      • 1970-01-01
      • 2015-10-23
      相关资源
      最近更新 更多