I'm quite new to Swift and am working on an app where I'm not sure how to setup the navigation. It works with a tab bar, except that I want the bar to display nomatter what view is being displayed. There are 4 "main" views that the user should always be able to get to. The problem comes when I get into subviews of one of those main views.
I have the tab bar with the 4 icons for the primary views. It's currently displaying the "activity list". When the user clicks on an activity, it will display a list at the next level of detail. However, that view is not one of the primary ones that is represented in the tab bar, so it has no tab bar and no way to transition directly to one of the primary views. You have to back your way out to the Activity list before you can select a different tab.
Say that the main views (represented in the tab bar) are A, B, C, and D. I want to be able to display the same toolbar on all sub-views (e.g. C-1, C-2, etc.) and allow direct transition to any of the other main views, without the user having to manually back out of each sub-view.
What is the "best" way to accomplish this?
1) Should I be creating a custom toolbar object that gets implemented on every view controller?
2) Should it be a combination of tab bar and tool bars?
3) If I have drilled into a stack of views, do I need to pop all of those views individually before I can switch to a different tab?
4) What do I use as my "root" view?
Thanks for any suggestions. I have hunted, but haven't found an example of a scenario quite like this.
I think I figured it out. I needed to embed each "tab" view in a navigation controller.
So...
Tab Bar Controller --> Navigation Controller --> View Controller --> "view stack"
The tab bar now remains at the bottom for every view, and if I touch the tab icon a second time, it goes back to the original tab view controller.
Related
I'm started to work at new place as iOS programmer. I joined existing project and got an assignment that i don't really know how to approach.
So my problem is this: when you press a button, next window has to have a tab bar with four icons, this means four different navigation stacks. Its not that hard to make, but in main screen i have more then four icons, and if i press any one of them next window always has to have a tab bar with four static icons, like shortcuts or something.
So what should I do? Does anyone had the same situation? I want to start with a good advice to save trouble later on.
You should probably rethink the app design. Tapping an item on the tab bar shouldn't result in a different number of tab bar items, as it leads to an unstable and unpredictable UI.
While not the most efficient in terms of visible content, you could introduce a segmented control (or a similar custom view) on top right under the navigation bar (if there is one), as seen in the Facebook app (though here it is used to perform actions, not changing views).
Your root view controller should be embedded in a navigation controller. Then push a view controller which contains any number of tab bar items not TabBarController. Then you can present each view controller either push or custom.
I've got a problem with my application UI.
I want to link 2 tab bar controller to one view, but I don't know how to represent it?
To give you the context of my application, I have a series of views controller that give some useful support information for my app. I want theses view to be displayed on both of my tab bar controller menu (one tab bar controller is displayed when the user is logged in, and the other when he's not)
I thought of putting a view controller between the tab bar controller and the navigation controller, which could trigger the view I'm looking to display 'twice', but for some reasons I couldnt get it to work. (I'm not sure if it's the best implementation, too)
Here's a screenshot of what my storyboard look like right now:
http://img836.imageshack.us/img836/5913/41321932.png
I have a little app that shows a list of dvds, then you can drill down from the table view and get some details. It also has a tab bar at the bottom and you can switch from dvds to bluray as tab buttons. This all works fine.
In reading about tab bar apps, I saw a demo that once you added more than 5 tab bar buttons, "more" would show up and then you can drag-n-drop the buttons like in Apple's Music app, which is cool! I also noticed that each tab bar button controlled a separate navigation controller, which was a new technique to me.
When I created my app, it had a single navigation controller and I added a view controller with the top of the view being a table view and the bottom of the view a tab bar. I then drag buttons to the button bar and can add more than 5 buttons and "more" doesn't show up.
So, I figure, it needs to to be a different navigation controller design.
I am confused on if I can take my app and embed a tab view controller or if I can adapt what I have or not.
Right now, since all tabs are basically the same (a table that drills down to a detail view) I just reload the data from a different file when the tab is switched. Nice and clean.
If I switched to the tab view controller concept, it seems wasteful to create 5 navigation controllers with 5 table views that drill down to 5 detail views. Plus what if I wanted 7? or 9? (I do realize (or guess) that I can give each 5 views the same class name, but still the UI has lots of storyboards…)
This is a design question to better understand what my options are.
Tab bar controller must always be the root controller of an application. (Unless it's in a split view, in which case the different sides of the split can be a tab bar controller - but it still has to be the root.)
So, the correct design for your app is: tab bar controller as root, each tab containing a navigation controller, each navigation controller having your table view controller as the first view controller. It may seem wasteful but if you think about it, each tab really needs to have its own stack of controllers, so there's no other reasonable way to do it. If user on tab 1 is 2 deep in a nav stack but tab 2 is 7 deep you don't want to switch between tabs and lose your place.
My iOS 5 app uses storyboarding with a UITabBarController. There are three "tabs" each displaying a view controller which has been linked using a relationship back to the UITabBarController. At the moment each view controller appears when you tap the relevant tab, as expected. However, for a more gracious transition I would like to slide the view controllers on and off screen.
By way of example, if I am currently on Tab 0 and then select Tab 1 the view controller on screen (for Tab 0) should slide off to the left-hand side of the screen, and the new view controller (for Tab 1) should slide on from the right-hand side of the screen.
I have been able to achieve this behaviour using a custom UIView as the tab bar but would like to know whether this is possible with a custom segue in storyboarding, as that would certainly save a lot of coding (and also would keep things a fair bit neater in the project)?
Thanks in advance for any assistance.
I am trying to do the same thing.
Unfortunately I think the relationship segue does not allow any customization as it just connect tab bar and the tab bar items together, and not a transition.
My guess is we have to do the transition ourselves when the view appeared.
I'm developing an iOS app just now with a Tab Bar navigation.
I have two screens which show the same information but in different formats (say, list and grid).
The two screens are different enough that they require separate controllers.
Users can toggle between the two views from a shared control bar button (toggle) at the top.
Scenario:
User presses the 'Places' button for the first time and it shows the places as a list.
They press 'grid' to see the same places displayed as a grid.
The user presses another tab bar button to navigate to a different screen.
When they press the "Places" button again, the app remembers their last viewed screen for places was the grid so the grid view is shown.
The user may then toggle back to list view. etc...
Can anybody recommend the best approach to achieving this?
One approach is to use one view controller that manages both views. That way, you don't have to bother with synchronizing data or subverting the normal function of UITabBarController -- there's just one controller. Also, don't try to overload the meaning of the tab for that controller. Instead, add a button to both views that tells the controller to switch to the other view. That'll be easier for your to build, and (more importantly) easier for the user to understand. It's not nice to make familiar controls do unfamiliar tricks.
If your view controllers are such that combining them into one would be complicated, then you can use two controllers and simply swap them in and out of the tab bar by modifying the tab bar controller's viewControllers array. You can still avoid having to sync data between them by having both controllers refer to the same data model.
I was trying to achieve this same thing, and it can actually be done with a basic setup of a TabBarController, NavigationControllers, ViewControllers, push segues, and unwinds.
TabBarController
|==> NavigationController --> PlacesController(grid view) --(push segue from nav bar)--> PlacesController(list view)
|==> NavigationController --> OtherController
|...
Make sure to have an unwind segue back from the list view controller to the grid view controller.
If you toggle between views then go to another tab (e.g. otherController) and come back, you'll return to the last view you were seeing because that's what is at the top of the stack of the NavigationController.