【问题标题】:MFMailComposer toReceiptsText with delayMFMailComposer to ReceiptsText 延迟
【发布时间】:2015-07-28 06:49:08
【问题描述】:

我将 MFMailcomposeViewController 用于邮件功能。 但是当应用程序出现 MFMailComposeViewController 时,toReceipts 文件中的文本会延迟显示。为什么会这样?

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")
    });

    }

【问题讨论】:

  • 问题现在仍然相关,并且接受的答案没有提供任何可服务的解决方案。

标签: ios swift mfmailcomposeviewcontroller


【解决方案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 上测试过

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 嗨,另一个问题是,当 MFMailComposeViewController 显示到收据 texfield 进入时,它会出现在正确的位置。你知道怎么解决吗?
    • 这显然是不正确的。这不应该是公认的答案,因为它不会为查询带来有用的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多