SwiftUI share same navigation bar after clicking navigation link - ios

My app currently has a modal sheet that displays a view inside of a NavigationView. When I click on the NavigationLink I created, it takes me to the destination view in the same modal sheet, but I no longer have access to the navigation bar properties of the previous view (i.e. I can't set the navigation bar title or add navigation items).
I tried making another NavigationView in my second view, but this draws the navigation bar title 1/3 down the screen, and it also prevents me closing out of the entire modal sheet with my #Environment property-wrapped Binding variable. Does anyone have any ideas as to how I could fix this?
Not sure if this sounded clear at all, but I will be happy to clarify.

Related

Layout issues when working with TabController, NavigationController and NavigationView (SwiftUI) together

I am working on the iOS legacy codebase with some SwiftUI views built. Everything looks good when app gets launched, but the Tab Bar title will be missing when navigate to another screen (either ViewController or SwiftUI view). It happens when navigate at the first time, the tab bar title will keep missing even though pops back.
This is how the tab bar looks after launching at the first time.
This is how the tab bar looks after navigating the other screens.
One more issue that I am facing is the navigation bar will be duplicate when navigate to a ViewController from SwiftUI view. The top one will be the nav bar from SwiftUI with a back button, the duplicate one will be from ViewController below the first one without the back button. What I expect is either the one from SwiftUI view with nav bar title, or the one from ViewController with the back button.
The top one is from SwiftUI view
Does anyone have some ideas how to fix them? Thank you!

SwiftUI - Setting NavBar items based on Sheet or NavigationLink presentation

I have a view that is presented via sheet and navigation link. How can I tell if a view was shown via a Sheet or NavigationLink so that I can update my NavBar buttons appropriately? Right now, I'm using an "isModal" bool. It works, but is far from elegant. Building the navbar in the presenting view doesn't seem like a good solution. Is there a better way? Basically the same as this question except using SwiftUI How to check if a view controller is presented modally or pushed on a navigation stack?

Navigation bar breaks in Tableview / detail view inside Tab bar controller

This is a bit of a tricky one to explain here so I'm hoping the screenshot of the storyboard of the app I'm trying to build helps to clarify what I'm trying to do.
Basically the apps starts with a nav controller and table view, when you click on a cell in the table view you go to a tab bar controller with three tabs, each tab view has its own navigation controller and subsequently there is a navigation bar on each of them, so at this point there is a back button on all tab views which takes us back to the initial table view.
The first tab view simply has some text, the next has a table view with several table cells and the last has a map view with several markers. Both the table cell and the map markers link to a detail view via a navigation controller which shows more detailed information (both via named segues). It's at this point of clicking through to the detail view where the navigation is breaking, the detail page shows no navigation bar although it is there as the title text is set, but there is no back button and it seems that the navigation context / hierarchy has been broken here somehow. The appearance of the storyboard also reflects this as it shows no Back button on the navbar on the navigation controller or the Detail view.
Without initially getting into the code in any real way I am just trying to see if there is any significant reason why these type of structure / hierarchy is just now going to work. So, my main question is does this storyboard structure seem like the correct way to go about what I'm trying to do?
Here is the storyboard:

IOS using different navigation bars

I'm creating an application where I need to use two different navigation bars. When the application first opens up, the nav1 bar should be displayed with an image and a Login button .. when they login screen appears, there is no nav bar. After login, it goes to a Detail screen where I need to show a back arrow image, a screen title and a menu button with drop down options.
I'm using one View_Controller that all my Views inherit from. I've been working on this for days and I'm so lost, please help.
I'm a little confused about the structure of your app.
As I understand it, you want an initial view that is contained in a UINavigationController. Once someone taps the "Login" UIBarButtonItem on the UINavigationBar, then you have a view come up that is not contained in a UINavigationController (probably because it is a modal view that is outside the navigation flow of your app).
The part I'm confused about is where the Detail view comes in. Is the modally presented view dismissed while the Details view is pushed onto the navigation stack from the initial view? Why does the Details view need a back button? Does going back to the initial view effectively log out the user?
At any rate, you should be able to change the UINavigationBar for every view that is pushed on to the stack (that is also contained in your UINavigationController). If you are using Storyboard, you need to make sure that you embed the views pushed on to the stack in a UINavigationController. You can do that by going to the "Editor" menu, selecting "Embed in" and then selecting "Navigation Controller".
Let me know if I didn't understand your question or if you can post more details.
Navigation bar will be the same in the app. You can hide it, show it, change title, change background color, or background image on each view depending on your requirements. But there is only one navigation bar in navigation based apps.

UINavigationBar with Search icon - push modal search view when clicked

I am creating a Navigation-Based application. The nav bar has a search icon; when it is clicked I push a SearchViewController onto the navigation controller (containing a search bar and tableview).
I am hiding the table view when the search view loads in an attempt to have the previous view (the view from which the search icon was selected) show behind the search view, but it appears that the navigation controller is removing this view. If I add the search view as a subview on the appDelegates's window I can see the previous view behind the search view, but the app crashes when I click in the search bar (it doesn't appear to give control to the view controller attached to the search view).
I am looking for any suggestions on how to achieve my desired result?
Thanks.
it sure is late as a response... but uinavigationbar's push view...
pushes a new view controller, removing the old one from the active window...
if you want to have a search controller behave like that, you should use a UISearchBarController and set it's search bar as header of your original table view..
the searchbar controller will show and hide the search result table view, if you want the old table to be shown, you should change the table on the search bar, so it's transparent first.
Pushing a new view is not a solution because you totally change the old view (remove it from the window)
greetings

Resources