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, width: 0, height: 0)
            activity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
        }
        self.present(activity, animated: true, completion: nil)

 

posted @ 2020-06-09 11:48  徐家汇  阅读(556)  评论(0编辑  收藏  举报