MFMailComposer toReipiptsText延迟

时间:2015-07-28 06:49:09

标签: ios swift mfmailcomposeviewcontroller

我正在使用MFMailcomposeViewController来实现邮件功能。 但是当app呈现MFMailComposeViewController时,toReceipts中的文本显示为delay.why是这样的吗?

if MFMailComposeViewController.canSendMail()
  {
    var mailPicker = MFMailComposeViewController()
    mailPicker.mailComposeDelegate = self;
    mailPicker.setSubject("hello");
    mailPicker.setMessageBody(txtViewBody.text, isHTML: false);
    mailPicker.setToRecipients(["aashish01cs@gmail.com"])

    self.becomeFirstResponder();


    presentViewController(mailPicker, animated: true, completion: {
        println("Mail composer completion block")
    });

    }

2 个答案:

答案 0 :(得分:1)

我知道阻止MFMailComposeViewController跳转呈现的唯一方法是使用私有api调用,但应用程序将被拒绝...

    MFMailComposeViewController *mailComposeVC = [[MFMailComposeViewController alloc] init];
    // do your setup here

    UIViewController *internalComposeVC = (UIViewController *) [mailComposeVC.viewControllers firstObject];
    // call private method to layout the view immediately
    SEL privateSelector = NSSelectorFromString(@"_endDelayingCompositionPresentation");
    if ([internalComposeVC respondsToSelector:privateSelector]) {
        ((void (*)(id, SEL))[internalComposeVC methodForSelector:privateSelector])(internalComposeVC, privateSelector);
    }

    // present the MFMailComposeViewController
    [self presentViewController:mailComposeVC animated:TRUE completion:nil];

    // while presenting force the controller to set the recipient immediately
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [internalComposeVC viewWillAppear:FALSE];
        [internalComposeVC viewDidAppear:FALSE];
    });

我只用iOS 8测试了它

答案 1 :(得分:-1)

它会在模拟器中显示延迟收件人 在设备中,它不会延迟加载。