Tab Bar in UItableview - objective-c

I have written an iPhone app with about 5-6 screens (each is a UITableView). I have finished writing the app, and now the requirement came up to add a tab bar in the 3rd screen.
Basically, the structure of the app is as follows:
Screen 1: Name of restaurants (example)
Screen 2: On clicking one restaurant, you get a number of options, like 1. location 2. rating 3. cuisine etc. Clicking each of these options shows a separate table view with some information.
Now, I need a Tab Bar in the 3rd level of screens (location,cuisine etc) with the same options.. i.e. location, cuisine etc, so that a user can directly go to that option instead of going to the previous screen first.
How can I implement this in my code? Each of the view is a subclass of UIViewController.
Thanks!

Drag in a UITabBarController from your Interface Builder. Connect as many ViewControllers as you want to your UITabBarController, and connect your 2nd View Controller to your UITabBarController.
NOTE:
If you are not comfortable with the UITabBarController connections, just start a new XCode project for "Tabbed Application" and consider it as a starting point to your app (for inits and connections)

Related

UINavBarController connecting the same UIViewController to multiple navigation controllers

I have a storyboarded app with a chain of tableviews followed by a detail view. Kind of the classic iPhone app. There are 4 tabs and each one leads to a navigation controller.
The issue is I really want to avoid unnecessary glue code since the app is basically finished. If it was possible to connect the Search and Favorites (bottom two off the tab bar) controller as 'Root View Controllers' to the same UIViewController I would be done. However, this won't work since a view controller can only be the root view controller to one tab. So as you can see I've instituted two dummy UIViewControllers that forward you to the UIViewController in the middle. Now, unfortunately, I have to write code to make that central view controller a fake root view controller to disable the appearance of the back button, and prevent popping to the blank root when you double-tap the tab bar.
Has anyone got a more elegant solution?
This appears to be a flaw in Storyboards. One workaround would be to use simple view controllers for each navigation controller's rootViewController. Put a UIContainerView in each that points to the UIViewController you want to share.

Storyboard with NavigationController and TabController

It seems like this should be easy to figure out, but I haven't had any luck this afternoon. I threw together this quick, simplified storyboard mockup of my problem.
Basically, I would like the table view controllers below to also be in a tab bar controller (in addition to the already present navigation controller). The tabs would switch between the two table view controllers.
Right now, the view controller with the buttons acts as a sort of menu. Each button leads to one of the table view controllers. Ideally this view controller would not have the tab bar visible, and would only be reachable from back buttons on the nav bars of the table view controllers.
I've tried a few different ways of embedding into a tabbarcontrollers but none of them produce the desired result:
-I've tried selecting both table view controllers and embedding those in a tab view controller. The tabbar doesnt show up in simulator, and the 'unreachable scene' warning appears.
-I've tried embedding the initial nav controller into a tabbarcontroller. This creates a tab entry for the first 'menu' page. It also causes issues with push segues once I connect the tableviews to the tabview.
I would be fine implementing some programmatic options on top of the storyboard, I just chose storyboarding for this project since it's a relatively simple presentation of data.
What is the proper way of going about this? Thanks!
A tab bar controller needs to be the root view controller of your view hierarchy. It goes against the HIG and Apple's standards to put a tab bar controller inside of any other type of container controller.
From the Apple docs:
When deploying a tab bar interface, you must install this view as the
root of your window. Unlike other view controllers, a tab bar
interface should never be installed as a child of another view
controller.
So, the bottom line here is you need to rethink your design. One option would be to set the UITabBarController as the root view of your window, and then have each of your UITableViewControllers inside of a UINavigationController, which is placed inside of the UITabBarController. In this way, you still get the navigation bar, and stay within Apple's design guidelines (you also won't get those pesky warnings, and Apple may even be throwing an exception nowadays if you try to install a UITabBarController as anything other than the root view of the window).
I accept JMStone answer but we might get into situation where we need to put tab bar controller inside other controller especially table view controller.
Please refer Storyboard navigation controller and tab bar controller
and also the good example by Matthjin: http://cl.ly/VQLa
Hopes it help some one who want to put tab bar controller inside table view controller and wants proper navigation.

Splitview Control navigating views

I am working with the SplitViewController for the iPad for the first time and trying to convert me iPhone app to run on the iPad. I have a couple of cells in a section such as Name, Phone Number etc in a navigation controller that i would like to adapt to work with the split view. I essentially would like the User to view the fields they can enter on the masterview of the splitview and when they tap a cell, the corresponding view should appear in the details view on the right. Can anyone point me in the right direction to get this functionality?
If you are okay at doing some self-learning, I would suggest simply creating a Master-Detail application in XCode. IMO that has a pretty nice template of how to set up the master and view controllers in a split view, and it will properly set up your details controller to handle hiding the master when going portrait.
In your code where (I'm guessing) you push a new view on in the iPhone version, you should just check the device type (or if self.splitViewController is set), and instead of pushing a new view on, modify the detail. The detail view controller will always be set to [self.splitViewController.viewControllers objectAtIndex: 1]
If you want more fine-grain control over your split view controller (showing the Master View as part of the SplitView when in portrait, or hiding the Master in landscape as well), I'd recommend using the excellent MGSplitViewController on github

iOS - Storyboards - Link the same UITableViewController to 2 different UITabBarControllers

I'm working on a navigation style iOS app using Xcode 4.3.2, SDK v5.1 and storyboards. The user can take several routes through the app but there is one particular table view scene that is used whichever route is taken. I therefore just want to have this scene defined once, but be visible as a tab page in more than 1 different tab bar controllers. The storyboard designer allows these relationships to be defined, but when the app is run the table view scene only appears as a tab button in the tab bar controller that it was most recently connected to.
Am I trying to achieve the impossible? I would have thought if storyboard lets me connect everything up then it should be achievable.
Many thanks,
Jonathan

Need help with the tab bar and tab bar controller

My iPhone app has a login page (shocker i know) but when the user successfully logs in, I want a view with a tab bar at the bottom to load and populate the buttons with data from the specific user. I can not find any tutorials on the tab bar, just the tab bar controller and from what i've read and seen, you can only have a tab bar controller on the MainWindow.xib. If thats not true, please show me how to have a tab bar controller on a view other that the main window. This is driving me nuts. Beer on me for a solution. Thanks
I have the same exact thing going on in my app and I can sympathize with you. There really isn't much to go on out there.
For me, it starts in your AppDelegate. I would validate the login info there, if it was good, push out the tabbarcontroller. If not, just present the logincontroller instead. It can be a tad tricky, but if you start there, you should be able to use everything else to get what you need.
Use the AppDelegate to determine which controller to push. When you push the login and it is good, call back to your appdelegate to push the tab bar controller and kill off the login.
Hope this helps. Good Luck.
You certainly can have a tab bar controller in other places besides MainWindow.xib. An example of one being created programattically, is in View Controller Programming Guide for iOS. See the section on Creating a Tab Bar Interface Programmatically.
Now, you've probably seen this already, but the point is even though Apple's example is in applicationDidFinishLaunching, you could do it anywhere you launch a view controller, like in response to a button click.
A few things to consider though:
Tab bar view controllers aren't meant to be embedded inside a navigation controller (i believe it would give you errors). it's the other way around is recommended. It might make more sense to present a tab bar view controller modally.
In your specific case, it sounds like the best thing would be to keep it simple by letting the tab bar be the root view controller in the main window after all, and having your login screen be automatically popped up after launch (i.e present it modally) then after proper login, dismiss the log in screen to reveal the tab bar controller that was there all along.