Is it possible to have a UITabBar in such a way that the following things are possible.
Once the app opens, none of the Tabbar items are highlighted (not even the first one). (call it homeview)
if the first Tabbar item is selected it goes to the first view and so on.
Hide the UITabbar for certain Tabbar items.
Allow any subview to go back to homeview.
Any tips on how to go about doing this will be appreciated.
Thanks
I had a similar thing to do:
start with a navigation controller
at some point show an UITabBar with multiple controllers
from some controllers from the UITabBar continue the main navigation controller
from any controller go to the home view (on logout)
For this to work I pragmatically created the UITabBar and pushed it on the navigation stack and from the controllers in the UITabBar I pushed other views on the stack.
To navigate to the root controller you can use this:
[self.navigationController popToRootViewControllerAnimated:YES];
Related
I noticed that WhatsApp has a somewhat neat navigation behaviour on their iOS app. See the following:
There are two navigation stack behaviour here:
UINavigationController as a child of UITabBarController
UITabBarController as a child of UINavigationController
How to achieve both of this at the same time, just like WhatsApp? Does it uses a custom UINavigationController?
Currently my implementation only does number 2 and not number 1. I do know that to do number 1 I have to make the UINavigationController as a child of UITabBarController, but I will lose number 2.
However if I implemented both, I will get weird result where I get two navigation bar, like:
In the example you give, it looks like they have a UITabBarController as the root view controller. Settings is a view controller inside a navigation controller.
When you tap Data & Storage, it pushes another view controller on to the Settings nav controller's stack.
When you press Help it does the same - but the tab bar is hidden when the Help view controller is pushed on the stack.
See hide / show tab bar when push / back. swift for some ways to do this
I have an iOS app written in Swift with UITabBarController with 5 UIViewControllers. Now, I have a bunch of UIViewControllers that are not part of the UITabBarController. I'd like to be able to show that same tabbar but I have no idea how to do that. Any clue?
More details: This is one of the View Controllers that the tabbar has. I use storyboard references and split my view controllers into separate more manageable storyboards.
So, the big picture:
There's no initial ViewController since I use storyboardId to get to the initial Navigation Controller. From there we have a ViewController embedded in the same Navigation controller. In that ViewController, there are 2 Container views - one of the size of the bottom ViewController that contains the "hamburger" button that toggles the other Container View which has an embedded UITableView in. When a specific cell is selected it should go to Profile ViewController that's not even in the same storyboard. The segue is set to be Push. Either way, doesn't show the UITabBar on the Profile ViewController
how you doing?
I don't know if I understood, but you are trying to show tabbar after going to another screen, right? If the answer is 'yes', try to change your segue to show(e.g. push).
-----Edit-----
You can do with two ways:
Presenting Modally -> using Current Context
Use push(e.g.) with a navigation view controller, you can also hide the navigation bar if you go to Navigation controller -> Attributes inspector -> Navigation Controller -> Uncheck Shows Navigation Bar
Hope now it works!
Best regards
I am currently developing an app that has a TabBarController and each of the tabs contains a navigation controller. This way on each tab I can show details of the rows selected on a view by pushing the viewcontroller to the navigation controller. Each of the views also have an UINavigationItem above them. In this navigation item I placed a button.
But now I would like to change the viewcontroller for a certain tab, when clicking the button in the UINavigationItem, BUT the view(controller) I want to change to has to act like the root view controller of that tab.
So I do not want to push another view on the navigation controller, but just switch to that view (in the same tab) and have that act as the root view controller.
I cannot find a good way to do this, with actually having the views work correctly. They either do not dealloc when I switch views (which would be nice, because I want to keep memory usage to a minimum).
One way of solving this, might be that I add more tabs to my TabBar Controller and just switch to the right tabs when I click the button, but that would be a last resort.
Not really sure if I described this correctly, but I was wondering what the best way is to do this. My preference is having 3 viewcontrollers and switch between them.
Hopefully I understand your question correctly: you want to basically 'reset' your navigation controller to have a new root.
You can do this by telling your navigation controller that you want to display a new set of view controllers:
[navigationController setViewControllers:[NSArray arrayWithObject:newViewController]
animated:NO];
This will get rid of all view controllers currently on that navigation controller's stack, and reset the root view to newViewController.
I am having a bit of trouble with my navigationController in my app. I am using the Kal Calendar component - https://github.com/klazuka/Kal.
I have created the view controller and have go it to appear in the correct position within in my app i.e. Click on a new tab and init the rootviewcontroller as the KalViewController and it sort of loads correctly but the back button is visible on the navBar when it should be the rootView and it is clickable 5 times before going to the true root, it's hard to explain but I have no idea what is wrong.
i have tried it with a table view and clicking on the first element in the tableView takes you to the calendar which works perfectly but this is not what I want/need in the app.
Thanks.
It sounds like you have both a UINavigationController and a UITabBarController. Make sure that the tab bar controller is your “main” view and that there are separate UINavigationControllers for each view controller in the tab bar. The different tabs’ view controllers should not be in the same navigation controller’s view heirarchy.
I have created an UITabView application. Each view selected from the bar is a seperate controller with own nib file. I switch between them succesfully.
In the first view I have two buttons (check out the screenshot). When clicking them I want to switch to another views which are the parts of the current view controller. I use:
[self presentModalViewController:anotherViewController animated:NO];
That switches the view, but hides the UITabBar. How to keep the bar on the screen after the switch?
P.S. Sorry for the blurred image. I am not allowed to share to much info.
Well I think you are misusing the modal view controller. For a problem like this I'll say you should put them in a view controller stack using UINavigationController. Instead of making each tab a UIViewController make it a UINavigationController, then you can push and pop view controllers on it, which still show the tab bar.
See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
use: tabBarController.selectedViewController = newViewController
edit: UINavigationController is not needed here.