I've got a Preferences system that I've implemented as a sheet. Within that I have an export command that bundles up some data and then offers a share sheet. Under iOS 14, I could trigger this share sheet from the onDismiss handler in the Preferences sheet call. Under iOS 15, it appears that onDismiss executes before the Preferences sheet goes away, so my Share Sheet never appears.
Here's the code that activates the Preferences sheet, which includes the onDismiss handler:
.sheet(isPresented: $theCurrentLog.prefsAreVisible, onDismiss: {
if currentPrefs.thePreferences.exportToShare {
let av = UIActivityViewController(activityItems: [currentPrefs.thePreferences.exportURL], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)
if UIDevice.current.userInterfaceIdiom == .pad {
av.popoverPresentationController?.sourceView = UIApplication.shared.windows.first
av.popoverPresentationController?.sourceRect = CGRect (
x: UIScreen.main.bounds.width / 2.1,
y: UIScreen.main.bounds.height / 2.3,
width: 200, height: 200)
}
currentPrefs.thePreferences.exportToShare = false
}
let prefsToSave:APreferenceSet = APreferenceSet()
prefsToSave.thePreferences = currentPrefs.thePreferences
prefsToSave.savePrefs()
}
) { Prefs()}
That exportToShare boolean in the if statement is set inside the the Preferences sheet.
Again, this all worked under iOS 14. Any ideas how to fix it for 15?
Thanks