我使用下面的代码在WhatsApp和邮件上分享了一些网址。
@objc func onclickOfShareButton(sender:UIButton){
let myWebsite = NSURL(string:"https://myDomain/path/\(String(zoomLocation.index))")
let shareAll = [myWebsite ?? []] as [Any]
activityViewController = UIActivityViewController(activityItems: shareAll, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}当我与WhatsApp共享时,我无法选择需要与其共享的联系人。某些情况下,一旦选择了联系人,我就无法单击下一步按钮。
它可以在某些时候分享,但也会失败。一旦应用程序关闭并重新打开,它将工作2-3次。
任何帮助都将不胜感激。
发布于 2019-07-09 19:35:53
代码的问题是太多的计时器设置为repeats: true。当我将它们设置为"false“时,它工作得很好。
self.counterTimer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.fetchCount), userInfo: nil, repeats: false)定时器可能会触发指向ActivityViewController的指针,以便在共享时消失。希望这对某些人有帮助。
https://stackoverflow.com/questions/56786753
复制相似问题