0

嗨,我正在编写以下代码以通过 SMS 推荐朋友。

当我单击单元格时,短信应用程序会以文本打开,但是当我再次尝试第二次时,它会显示白色屏幕。

这是我的代码

var controller1 = MFMessageComposeViewController()
    extension ReferaFriendController:UICollectionViewDelegate,UICollectionViewDataSource,MFMessageComposeViewControllerDelegate
    {
    if indexPath.item == 0
            {
                if MFMessageComposeViewController.canSendText() {
                    let urlToShare = self.referalmodeldata[0].referralCodeOnly
                    controller1.body = "Hey I just gave an Awesome Assessment on  App you can also try it. I scored , Try to beat my score \(String(describing: urlToShare))"
                    controller1.messageComposeDelegate = self
                    self.present(controller1, animated: true, completion: nil)
                }
            }
    func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
            self.dismiss(animated: true, completion: nil)
        } 
    }
4

1 回答 1

0

据我所知,没有必要保留对MFMessageComposeViewController. 只需在 if 闭包内将其移动到您需要的位置即可创建:

if MFMessageComposeViewController.canSendText() {
    let controller = MFMessageComposeViewController()
    // ...
}
于 2019-03-14T09:06:21.167 回答