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

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!

Related

SwiftUI share same navigation bar after clicking navigation link

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.

Changing tabs on Tab Based Application Pushes UI Elements Down

I have a tabbed based iOS application. The fourth tab is linked to a UINavigationController. When I navigate to the home tab from the fourth tab, the UI elements of the home tab are pushed down. However, if I rotate the phone to landscape and then back to portrait, everything has moved up and is in the correct place.
In Storyboard, I set the top bar to none. I have the UINavigationBar hidden in the fourth tab/view controller before I navigate to the home tab.
Why would it be that the rotation fixes the constraints? How can I fix the UI elements such that they are not pushed down in the first place?
Here is a screen shot of my storyboard:
Your question doesn't really make sense. A 4th tab would not be embedded in a navigation controller. Instead, the 4th tab would link to a navigation controller. When you first select that tab you'd see the root view controller and it's navigation bar item. If you pushed a new view controller it would get pushed onto the navigation controller in tab 4. If you switch to one of the other tabs then the navigation controller will be swapped away and it's navigation bar will no longer be visible. Swap back to tab 4 you'll see it again, complete with it's navigation bar.
I created a sample app in order to confirm what I'm describing, as I haven't used tab bar controllers a lot, and not in quite a while I can upload the project if you really need to see it. It only contains a couple of lines of code (to implement the button on the navigation controller's view controller that creates and pushes a new view controller.)

iMessage navigation controller bar hidden when expanded

I'm working on a new iMessage app and am seeing some weird behavior. When I expand the app from compact to expanded the navigation bar disappears. To simulate it create a controller thats embedded in a navigation controller. Have it segue to another controller and in compact it acts normal with a back button. Expand it and the navigation bar is missing. I did the segue with a button tap and doing the flow when everything is expanded still has the issue.
There seems to be a bug in iMessage. This worked for me
https://agilewarrior.wordpress.com/2017/06/13/how-to-deal-with-imessage-navigation-bar-covering-top-of-view-bug/

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.

Tab Bar Controller - Show a view controller that is not one of the tabs

I wonder if this is possible. The design for this app I am working on is as below:
Two sliding views sit one on top of the other. The bottom view is a 'Settings' view. The top view is a tab bar view. We are using ECSlidingViewController for the sliding.
When the app is opened for the first time, the tab bar view shows with first tab selected.
When they tap on the hamburger menu or slide right, the bottom, settings view slides into view.
When they tap on an item in the settings view, like the About item, the corresponding view should be displayed inside the top tab bar view with none of the tabs shown as selected.
I think I am going to have to convince my team to not display the settings items inside of the tab bar, it seems just too twisted. But just wanted to know if anyone else has done anything like this and if it is possible to do it without introducing too much complication in the code.
I've done something with the same design with a menu that slides from the left and over the tab bars. I ended up putting a View Controller on top of everything else
Something like
[self presentViewController:AboutViewController Animated:YES];
Just make sure that you either put that view controller in a UINavigationController or something with a dismissViewController for users to return to your main page.

Resources