I have a view that can either be shown via another view or via the More tableview list of more controllers.
In the first case, I added a More button on the Navigation bar to take them back to the More view list, but what is the code that I put on the More button to take the user back to the More list?
Thanks
If you want to customize your backBarButtonItem check this SO question.
Related
I'm a new Swift developer. I'm using Swift 4.2 and XCode 10.2.
I have a tab bar controller with 5 tab bar items. In the view controller for each tab bar item there is a button to show the balance in a different view controller (call it the Balance View Controller). I have a segue from each button to the Balance View Controller.
I am using interface builder, but will be happy to add code.
How can I put the main tab bar on the Balance View Controller so when the user is done viewing the balance, he can select another tab bar item and keep going? I rejected using a navigation controller because the back button will interfere with the uniform view at the top of every screen and I don't want to adjust it.
I could not find any SO questions that address this issue. And all the other web resources I found are very basic on how to implement tab bars. Any help would be appreciated.
Another approach:
Load Balance View Controller as a Child ViewController, and display its view on top of the current view. This will leave the tab bar alone, allowing users to navigate to another tab.
Balance View Controller sounds like it's just an information display. If so, you can add a tap gesture to remove it from the current view on a simple tap.
If Balance View Controller is interactive, you can add a button to remove it from the current view.
Since you say you have a button in each tab's VC to show the Balance View Controller, then you probably also want to remove it from the current view when another tab is selected.
I rejected using a navigation controller because the back button will interfere with the uniform view at the top of every screen and I don't want to adjust it.
The best way to achieve this is with a UINavigationController what we can do about the Top navigation bar and the darn back button is we can hide the whole thing by
// Add this to your viewcontroller
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.isNavigationBarHidden = true
}
And going further if you want to you can disable the animations for the view controller
hope this helps
I have a UITabBarController with many UIViewControllers resulting with a "More" TabBarItem.
One of those views has some editing functions I'd like to place in the UINavigationBar and I can replace the right and left button items, no problem. However, there seems to be an issue when you move that view controller where the navigation controller is no longer displayed. I believe I can solve the issue if I know from where the view is loaded from.
Here is my challenge I need some direction on:
What is the best way to check to see if the selected view is not being presented with the top navigation bar? Meaning, there is no "< More" on the top. That way I can display my own Edit button.
Any view controller can ask for its tabBarController. From there, it can get the tab bar controller's moreNavigationController. So now it can ask whether its parent is the moreNavigationController.
Should be able to check if there is a left bar button item using
navigationItem.leftBarButtonItem == nil
or
navigationController?.navigationItem.leftBarButtonItem == nil
depending on your hierarchy.
In my app I have this storyboard:
and I would like to add a back button from the second table view back to the first. So I inserted a Navigation controller in order to have a navigation bar in the second table view ad I have created a segue with its identifier from the second table view to the first. But then how can I add a back button? I have tried to drag a button from the library into the navigation controller but it won't let me do it...I had already done this but in this moment I can't remember how.
Please can you help me?
In above image you shared you are making your tableview controller as root view controller.You have to kept your navigation controller on root. As you can see in attached image and you don't have to make back button manually as navigation controller has its own default back button.
This example is right how to make storyboard.Try it
self.navigationController?.navigationBar.hidden = false
In setting of UINavigationController set up like on screenshot
If you're using a navigation controller and its default navigation bar, you don't add an explicit back button--the navigation bar does it for you. You can add a UINavigationItem to your view controller, on which you set a title, back button title, etc.
I would like to introduce in my app a View that will contains both navigation bar and a tab bar at the bottom. View contains a Table View with multiple entries and once user tap on a cell a push segue takes him to another view with details regarding the cell he has previously tapped. If he decides, user can go back to parent view by tapping on 'Back' button of the navigation bar on top. In addition to this, I would like my view to have a tab bar at the bottom with extra tools for the user. So, if he decides to check the 'Creator' of the app, he can by simply tap on 'Creator' TabBarItem at the bottom.
I would like to ask you what is the best way to achieve the above. I have already tried to use UITabBarController combined with UINavigationController. Didn't achieve what I was looking for because I would like the view with the table on it to be independent from the TabBarController and NOT a part of it (by part I mean by accessible through tabs).
Do you believe a UINavigationController view with UITabBarView would be a better choice?
UPDATE
What I mean by, "independent from the TabBarController and NOT a part of it":
Once the app loaded, I would like to see my main view (with table) contains Navigation Bar on top and Tab Bar at the bottom. However, I don't want to see the first tab of the Tab Bar selected because my main view will not be accessible through tabs of the Tab Bar but through Navigation Bar. If, for example, I am in Main view and tap on 1st tap, I would like to move to another view that will contains some other info.
Option 1:-
Create a tab bar Controller and on that TabbarController assign your navigation Views.
say nav1 with tab1 , nav2 with tab2...
Option 2:-
Create a Navigation View Controller and than add the tabbarcontroller on that navigationView Controller by using addSubView.
So when the user clicks on a row in a table u will go to a different View which doesn't have the TabbarController and when the user comes back he will again see the TabbarController.
This is what I will do:
First I will subclass UITabbarController and create for example ParentTabBarController. This controller will contain all the tabs necessary and what they will do if they are clicked so on.
Next for each viewcontroller I create, I will subclass from this ParentTabBarController so that the tabs are already in. You can add additional functionality or override it depending on your situation.
In your appdelegate pass in a navigation controller and every time push and dismiss the viewcontrollers you created in second step.
Hope this helps..
I have an application which has 5 tabs. I also have another view which you can access from tab3 via a selection of buttons. I will call it view 3b. View 3b populates with information based on which button the user selected in view 3. After the user puts in all the information required the app automatically takes them back to view 3. I want to add the tab bar to this view(3b) but I do not want it to have its own tab. I just want to use it so the user can navigate out of this view back to the rest of the app if they want to exit the screen early. Does anyone know how I can attach the tab bar to this screen without having a tab added for this screen. I am using Xcode 4.6.2 and am using storyboards to set up my app.
Any help would be appreciated. I've done a bit of searching but everything I find just explains how to use tabs.
Any help would be appreciated. Thanks.
It sounds like you need to use a UINavigationController.
When you set up your UITabBarController, instead of linking the third tab directly to your 3rd view controller, connect it to a UINavigationController, and then set the root view of that UINavigationController as the UIViewController you want as your third tab.
From there, you can set up your buttons to perform a push segue to your second view controller (view 3b from your question). If you do this, not only will you keep the tab bar on view 3b, but a back button will automatically be placed in the top left of the page so the user can simply go back to view 3. If you don't want the navigation bar that appears to be there, you can instead uncheck the "shows navigation bar" checkbox in the UINavigationController's attributes inspector.
I hope this helps!