为了更新共享表以在iOS 13上工作,请创建一个IF/ELSE语句,首先检测iOS 13与所有其他版本的比较。
class CatseyeViewController: BaseViewController{
@IBOutlet weak var sliderImage: UIImageView!
@IBAction func share(_ sender: UIButton) {
let version = OperatingSystemVersion(majorVersion: 13, minorVersion: 0, patchVersion: 0)
if ProcessInfo.processInfo.isOperatingSystemAtLeast(version) {
/* runNewCode()*/
let items = [self.sliderImage.image]
let ac = UIActivityViewController(activityItems: items as [Any], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(ac, animated: true, completion: nil)
if UIDevice.current.userInterfaceIdiom == .pad {
ac.popoverPresentationController?.sourceView = UIApplication.shared.windows.first
ac.popoverPresentationController?.sourceRect = CGRect(
x: UIScreen.main.bounds.width / 2.1,
y: UIScreen.main.bounds.height / 2.3,
width: 200, height: 200)
}
}
else
{
/* runOriginalCode() that works for earlier IOS*/
let activityController = UIActivityViewController(activityItems: [self.sliderImage.image as Any], applicationActivities: nil)
self.present(activityController, animated:true, completion: nil)
if let popOver = activityController.popoverPresentationController {
popOver.sourceView = self.view
}
}//end of else statement
}//end of share function
}//end of controller