Add a navigation control to a single tab in xcode 4 - iphone

I am fairly new to programming with objective-c and xcode 4 and I am trying to make a tab bar application and add a navigation control to a specific tab.
I am able to add a navigation controller inside the tab bar controller, by clicking dragging the navigation controller into the tab bar controller of the MainWindow.xib window. However, by doing this and linking the class and nib to the corresponding view controller and view, respectively, this adds a new tab, which I don't want (as I want a specific/already in existence tab to also contain the nav controller).
Thanks.

I'm not sure what you exactly want to do, but as my understanding, you want navigation controller under tabbar item that is already existed in the tabbar controller. It's not good practice to do it in that way. Rather than that, try add navigation controller first and then add ViewController inside of it (which makes your life easier). Usually Navigation Controller is root of ViewController, but not vice verse. Hope this help.

Related

Interface builder's not showing the navigation controller's navigation bar inside a UITabBarController

I recently switched to Xcode 4 from 3.2 and so far everything's been fine. There's one thing that's driving me nuts for the last hour or so. In my main window xib, I have a Tab Controller with 4 tabs. Three of them are regular UIViewControllers, but one is a UINavigationController. The problem is that with Xcode 4's Interface Builder, I can't see the navigation controller's navigation bar. I just get a window that says "Address List Table View Controller inside of a Contacts Navigation Controller". Why doesn't Xcode show the nav bar? In Xcode 3's IB I could see it, add buttons, change the title, etc. I can't seem to do that here.
If you watch this video, the person drags a UINavigationController into the tab bar and you see the bar just fine.
http://www.youtube.com/watch?v=aSBK8Zz6O4M
I set the custom class to my ContactsNavigationController, and the changes I make in the nav controller's xib don't reflect in the tab controller like the regular view controller's xib changes do.
So, I'm a little confused. I'm not new at this, I've been at Xcode programming since Day One, but I'm quite lost as to why the nav bar doesn't show up in the tab controller's view, and why when I set the nav controller to my custom class (even set the nib file), it doesn't work. Everything else does.
i just had this issue on an older project. i changed the size in the properties for the root view controller and this seems to have flushed interface builder, including it showing the navigation bar on views that were linked to nav controllers, but in IB had no nav bar displaying

IOS Storyboard when to use navigation controllers?

Hi I'm new IOS and have been using the storyboard feature, I followed this tutorial which resulted in a working app. I'm slightly confused when to use a navigation controller. In the tutorial above, every tab had a navigation controller. Is this necessary?
I'm in the process of creating a new app and it seems to work whether I add a navigation controller or not to each tab (see pic).
I'm just curios what is the correct process?
Thanks.
As your app is using a UITabBarController each tab will display a separate 'branch' of views. If any of these 'branches' needs its views to be wrapped in navigation functionality (or simply display the navigation bar with a title etc) then you would add a 'UINavigationController` as the primary view controller for that tab, in between the tab bar controller and the first view controller you wish to display for that tab.
If you want a tab to simply display a view controller which doesn't need hierarchical navigation or a navigation bar then you wouldn't need to use a UINavigationController and can directly set your view controller as the controller for that tab.

Unhide tabbar when a new view is pushed

I have UITableViewController embeded in a UINavigationController in my app. When a row is selected it pushes a UITabBarController. So far so good. The problem is that some of the tabs I push more views but the tab bar gets hiden. I've tried setting hidesBottomBarWhenPushed = NO, but it doesn't work.
I'm using XCode 4 with storyboard
Any ideas?
I've had this problem in one of my apps (though it was in iOS 4.x, using nibs not storyboard).
What I did to solve it: You want to have the root controller for each tab (the one with tabitem, etc) be a navigation controller - and when you push new views onto this navstack, they will respect the top navigation bar and bottom tab bar (they may actually display two navbars, so you have to be careful, but generally this is the way to go.)
first of all you might want to take a look at this
viewController: The view controller that is pushed onto the stack. It
cannot be an instance of tab bar controller.
so pushing an instance of tab bar controller is not recommended. There's a good reference there that might accomplish the task you wanted ill just provide the link here

Changing viewcontroller for a tab in a tabbar controller

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.

Problem in adding more than 5 button in tab bar controller in iphone

Hello everybody i need your help.
I am making a tab bar based application in iphone. i have more than 5 button to show in tab bar. when i did it, five button displayed fifth button is more..... but when i clicked on more then more button came in a table view not in tab bar.
That's how it works. From the documentation (http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html%23//apple_ref/doc/uid/TP40007457-CH102-SW2):
If you add more than five items to the
viewControllers property, the tab bar
controller automatically inserts a
special view controller (called the
More view controller) to handle the
display of the additional items. The
More view controller provides a custom
interface that lists the additional
view controllers in a table, which can
expand to accommodate any number of
view controllers. The More view
controller cannot be customized or
selected and does not appear in any of
the view controller lists managed by
the tab bar controller. For the most
part, it appears automatically when it
is needed and is separate from your
custom content. You can get a
reference to it though by accessing
the moreNavigationController property
of UITabBarController.
That is intended behavior and not an issue, if you read the viewController Programming guide you could have seen that right away: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457