-1

I am doing a project where I am implementing the SwiftUI default navbar [navigation view and navigation link] and then I created my own custome navbar for the rest of the screens.

So, I am using the SwiftUI navbar for the login process in my application. But after the user logs in, they are taken to the homepage. This is where I implemented my own navigationBar style.

Now you see, I linked the login button with the homepage using: NavigationLink(destination: HomepageView())

You see where the problem is, it's like I'm nesting 2 navigation views and so I'm getting 2 navigation bars. I want to hide the default navigationBar that came from the login process. So I tried using the [.navigationBarHidden(true)] but it does not work at all.

In short, how do I implement 2 navigation Views [one default, one custome] where I can use one for a section of my app and then the other for another section without having them to collide like this.

The best i could find was:

//added this to my HomepageView() .navigationBarTitleDisplayMode(.inline) .navigationBarHidden(true)

The navbar display mode changes to inline, but it is still there :)

I'm really a beginner still, so can you please help me.

Deem
  • 1

1 Answers1

0

Just have two UIViewControllers, one for the login and one for the home view.

So when it comes to redirecting from the login view to the home view. Do not redirect via NavigationLink because then you will end up with the same problem. (And it should not be possible if you do it properly, because your login and home views are held by their own UIViewControllers.)

Just close (viewControllerLogin.dismiss) the login view and (vieControllerHome.present) present the home screen.

If you google a bite you basically can wrap a (SwiftUI) View into a UIViewController should not be a problem. (it is quite common to do that.)

Something like that: Example

MichiK
  • 127
  • 6