When I run the following code, it works fine on iOS 4.4 and up, but on iOS 4.5, the alert does not show up and the following log is output.
2021-05-08 18:21:34.680280+0900 SampleProject12.5[2534:139985] [Presentation] Attempt to present SwiftUI.PlatformAlertController: 0x7ff27200ce00 on _TtGC7SwiftUI41StyleContextSplitViewNavigationControllerVS14NoStyleContext: 0x7ff26f825000 (from _TtGC7SwiftUIP13$7fff5695965428DestinationHostingControllerVS7AnyView: 0x7ff271c06180) whose view is not in the window hierarchy.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: NextView()) {
Text("Next View")
}
}
}
}
}
struct NextView: View {
@State private var showingAlert = false
var body: some View {
Button("Show Alert") {
showingAlert = true
}
.alert(isPresented: $showingAlert) {
Alert(title: Text("Alert!"))
}
.onAppear {
showingAlert = true
}
}
}
6
0
1.7k