Hi,
i had a code that worked perfectly with IOS 14, and now gives yellow warning + crash on IOS 15.
It is for simply have a popup to share things (links, image, pdf... whatever).
The code :
// for windowLevel, i used 0 if the view were at the top of the app, 1 if it was in a view that was allready a sheet for example.
DispatchQueue.main.async {
if let vc = UIApplication.shared.windows[windowLevel].rootViewController {
shareActivity.popoverPresentationController?.sourceView = vc.view
shareActivity.popoverPresentationController?.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height, width: 0, height: 0)
shareActivity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.down
vc.present(shareActivity, animated: true, completion: nil)
}
}
This crash now on IOS 15, and before compile appends a yellow warning that says "'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead".
I understand that it is for multi opened windows reasons, I tried a lot of things but never succeed to apply the warning advise.
Is there anyone who has an easy way to use shareActivity on SwiftUI ? Thanks !