Post

Replies

Boosts

Views

Activity

How to switch SwiftUI Views?
Hello. I am stuck on this one problem, and I can't fix it. I'm very new to Swift, but I have used other languages. I searched all over the internet, and it does not work. I tried doing something similar to this: Button("Press Me") { view2() } It doesn't do anything. It's spelled correctly. If it helps, it also gives a warning of "Result of 'Username' initializer is unused" Does anyone know why this is happening?
4
1
6.5k
Sep ’22
SwiftUI not changing views when button pressed.
Hello. I am trying to make a signup/login page, but I can't fix this problem. I am very new to Swift, and everything online says what I am doing is right, but it won't work. I have 2 files, ContentView, Login and SignUp. When I do this SignUp(), or Login() it doesn't change views and stays the same. This is what I have tried on ContentView() Text("Hello! Welcome.") Button("I'm new") { SignUp() } Button("I'm returning") { Login() } It also gives a warning saying "Result of 'SignUp' initializer is unused" on both files. Does anyone know how I can make it so that when the button is pressed it actually changes views? Thanks!
1
0
994
Oct ’22