0

So, I Need To Switch To A View In SwiftUI. without A NavigationLink or button. Heres What I Want:

if "Condition" == "Variable" {
    CODE HERE
}

So If I Have 2 Views, (ContentView And MainView) I Need To be Able To Switch From One To Another With Code. So If A Condition Is True,False, or Anything, I Can Switch Views. Thank You For Your Time.

pawello2222
  • 46,897
  • 22
  • 145
  • 209
  • [This](https://stackoverflow.com/a/59592697/9607863) looks like what you need. – George Jan 21 '21 at 23:57
  • Yes. Thank You So Much. I appreciate It. – Swiftly Programming Jan 21 '21 at 23:58
  • One More Question Though: (Stack Overflow Has A Question limit For Me) I Just Wrote A Lot Of Code, And Then I Got The Error "The compiler is unable to type-check the expression. Try breaking the expression up into distinct sub-expressions. How Do I Do That? – Swiftly Programming Jan 22 '21 at 00:02
  • This question has been asked many times before, without a doubt you'll be able to find lots of answers. Otherwise, similar to this post, it gets closed for duplicate. Anyway, it's likely either you forgot to pass in some parameters to a view or have a really large view `body`. If you have any more questions, you can find it all online. – George Jan 22 '21 at 00:04
  • Sorry To Come Back, But Does The Statement ExampleView() Switch The Current view? It Does not Change For me. Can You Show Me How To Switch Views With A Statement? – Swiftly Programming Jan 22 '21 at 02:20

0 Answers0