how to push a view after x seconds in swiftUI without any interaction?
NavigationView{
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now()+1.0) {
NavigationLink(destination: pageViewUi()) {
EmptyView()
}
}
}
}
You can handle it it this way :
struct ContentView: View {
@State var show = false
var body: some View {
NavigationView{
NavigationLink(destination: Text("OK"), isActive: $show, label: {
EmptyView()
})
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.show.toggle()
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With