Post

Replies

Boosts

Views

Activity

Reply to SwiftUI - Show alert when go to new page
I was solve with this code changes struct SecondView: View { @State var showAlert = false var body: some View { // i want to show alert when navigate to this view VStack{ Text("Second View") .alert(isPresented: $showAlert) { Alert(title: Text("You are in second view")) } }.onAppear{ showAlert = true } } } thanks all
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to SwiftUI - Show alert when go to new page
ContentView.swift struct ContentView: View { var body: some View { VStack{ NavigationLink(destination: SecondView()){ Text("Go to second view") } } } } SecondView.swift struct SecondView: View { @State var showAlert = true var body: some View { // i want to show alert when navigate to this view VStack{ Text("Second View") .alert(isPresented: $showAlert) { Alert(title: Text("You are in second view")) } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21