iOS swift ipad使用系统自带分享 弹框失败没有弹框

是因为iOS13上的不支持适配

let activity = UIActivityViewController(activityItems: [URL(fileURLWithPath: path)], applicationActivities: nil)
        
        activity.excludedActivityTypes = [.print]
        
        //需要做一个 iPhone 和 iPad的判断
        if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
            activity.modalPresentationStyle = .popover
            activity.popoverPresentationController?.sourceView = self.view
            activity.popoverPresentationController?.sourceRect = CGRect(x: Screen.width, y: Screen.height/2,  0, height: 0)
            activity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
        }
        self.present(activity, animated: true, completion: nil)
原文地址:https://www.cnblogs.com/xujiahui/p/13071656.html