How to set button on navigationbar in tabbased application? - iphone

I am working on a project which involves both kind of applications ie Navigation based and Tab based. All things are working perfectly. But what I want is, when I click on a particular tab then a button must be added to the navigation bar at the top to edit the table below it. I am able to draw the button but it is not affecting the tableview below it. When I do this in navigation based application it works perfectly. But it does not work in tab based.
So please tell me the way to add button at navigation bar in UI tab based application which appear only at particular tab.
tell me the sample code or any tutorial for it.

For each tab embed a UINavigationConrtoller, and your own view controllers in them.
This way each tab will have its own navigation bar, and thus can have their own sets of bar items, titles, etc.
You generally never want to embed a UITabBarController in a UINavigationController, always the other way around.

Related

Need an ideal way to handle tab bar in app

I want to create an app where there is a login screen, and when user logs in open up home page with tab bar controller.
I have created a single view application and have created login screen, home screen and a tab bar on it.
In tab bar delegate, I am adding screens to tab bar by [self.view addSubView firstView.view]
My problem is if I open up 4th tab, and switch to 2nd tab and I have to go back to home screen, so I press home btw on nav bar, it shows view 4 which is already on stack of uiviews.
How do I switch between all tab bar views and add navigation to them ? Which ideal method is to be used?
I've created app that is doing what you need (I guess). You can find it in app store for iphone using name Torchoo. It is free and there is test account so you can see how it works and if its really what you need. If yes, ping me here I will show you the sources and how I did it.
In couple of words, you need normal tabbar controller that has number of navigation controllers and each of them has number of view controllers. And login screen is just a modal view that shows/hides when you need it. Most of things may be done in storyboard.
I don't get it actually but i think you want to attach all the view by navigation controller.
But it's useless. if you want to use navigation bar then it ll navigate in another view but tabbar will give you different views on every tab.
so, first see the use of both of them then ask....

Is there a way to implement four tabbed uitableviews that all have the same uinavigationbar

I am working on a mobile version for my company's web app. The structure of this application requires uitableviews with a tab bar on the bottom and a navigation bar up top to return to the previous view. As you drill down in the application the tab bar items change at each level allowing selection of different views pertaining to that specific level in the app. I need a way to implement this with a navigation bar on top that navigates back to the previous screen on every tab in said tab bar when a back button is clicked on any of the tabs.
for example: let's say i start out with an items tab and a simple about tab. When i click items it drills down to a new view called subitems and the tabs for this view are subitems, favorites, details, and notes. I want the navigation bar to go back to the previous screen when i click the back button on any one of these four tabs.
Is this at all possible? I can't seem to find anything related to this type of structuring within an app. any help/examples would be greatly appreciated.
I know that a negative answer always sounds bad, but I tried to do the same a few months ago and I could not find a way of doing it using the standard UITabBarController/UITabBar. Take also a look at this question/answer.
The good news is that it is not that difficult to implement from scratch a tab bar controller that can be pushed on a navigation stack. There are also several examples around, one is BCTabBarController. GtabBar is another example.
I actually found a way to do it you just have to implement the navigation bar's leftbarbuttonitem instead of the traditional back button. Then I just created a method that is invoked when the back button is pushed this updates the navigation stacks of all four views within the tab bar and sets the tab bar items accordingly to match with the previous views we are navigating back to. . . so long story short...it is possible.

iOS: How to properly use Navigation Controller without any visible user interface

I have an application that seems best suited for a navigation controller. There are a few places where navigation splits off and is not completely hierarchical but I think I can remedy that just using a modal view at those points.
I want to know if this is the best way to navigate through multiple views or if there is a better way. I want the user to be able to progress through several steps but be able to go back a step or even return to the beginning at certain points.
Additionally, I want to be able to do this using custom buttons. I want to use the entire screen without any navigation bars, etc. I figured I could push and pop the stack with my own custom buttons but I want to know how to make sure the screen is totally usable by me.
As far as I know, Navigation controller is the best way to navigate among views, you can go back and forth between views using navigation controller easily, even you can present navigation controller as modal view. You can specify your own custom navigation items in navigation bar. And if you do not want navigation bar, you can hide navigation bar. pushing and popping is the best way to implement navigation among views.
#gonzobrains
I have been in that situation!
Here's what I'd do:
"Hide the navigation bar" using the setHidden property. At places where you want the navigation bar to be seen, I suggest you use a UIToolbar with custom buttons. (its almost impossible to differentiate)
to go back one step you can popViewController
to go all the way back you can use popToRootViewController (like the top right corner button in the IMDB app)
There is no reason why you should not be able to use a navigation controller without using the navigation bar.
Hope this helps!
Keep the nav controller, but you can hide the nav bar easily enough. It could be a viable solution, but make sure your implementation is solid and clear; otherwise you may be rejected. A possible alternative would be to have pages side by side, as in the weather app…but it's your decision as to which paradigm is best.

Best iPhone app approach for project

I'm building an iPhone app and I'm sort of confused about which approach should I choose for views and controllers.
I would like to have a tabbar at the bottom with three options. I would also like to have a main view displayed when the app shows (along with the tabbar) but I don't want this view to be part of the tabbar options.
So, when the app begins, the tabbar has no option selected but the main view displayed. When a tabbar options is selected, in its top bar it should display a back button to the main view. When the back button is pressed, the main view display again with no tabbar option selected.
Which approach should I choose?
Hope it makes sense.
Thanks.
I understand what you're trying to do, but you shouldn't do that. I don't like that design at all. You should have one navigation controller for each tab.
You should probably read Apple's Human Interface Guidelines as it's possible they would reject your App if they thought such an implementation with a TabBarController was confusing.
As an alternative, you could possibly have the "main view" as you call it accessible with a button in the Navigation bar at the top and then add that to all three tabs. Not necessarily a better design but you probably wouldn't be breaking the guidelines.
A better alternative might be to use a UIToolBar at the bottom instead of the Tab bar which has the three buttons spawning your views modally which can then be dismissed as you suggest.
Remember though, your App's users have built up a knowledge of how App's are generally supposed to navigate, feel and control so you should think carefully before deciding to go against that.
Firstly, I think you should reconsider giving your Main View it's own tab. That way it's a no-brainer for the user to return to that screen. BUT, if you STILL don't like that idea, read on...
The UITabBarController has the unfortunate side effect of not being able to be removed once created (even if you delay it's creation by instantiating it programmatically).
SO...
Option 1: Make your MainView a modalPresentation sub-view, displaying it ON TOP of one of the views in your tab bar (hiding the tabs until you're ready to show them again).
Option 2: Give a subview of your first tab a...
mySubViewController.hidesBottomBarWhenPushed=YES;
This will make the UITabBarController disappear temporarily (just on that view, until you're ready to show the tabs again).
Both options seem kinda messy to me, but they are possible. Depends on how well you execute them, I suppose.
Hope this helps!
You could add the main view as another tab.
OR
You present the main view modally when the app starts over the tab bar views.
The first option would be used more if the view holds the same kind of content as the tabs, for example if the app was an online store, the tabs would be Categories, Search and Recently Added, with what you call the "main view" being the Home page (showing offers or something). (So all the views/tabs would be showing products on the store)
The second option would be more if the content of the main view is different to the tabs.
Keeping with the online store example, if the tabs were Categories, Search and Recently added and what you call the "main view" being a login/logout screen. (so the tabs would be showing products, but the modal view ("main view") being more admin related, and it's main purpose not being to display products.

How to hide tab of the tabBarController?

I want to create a Tab in the TabBarController but i don't want to show that on the tabBar...i mean it should be there but invisible...
like I have 5 tabs in my tabBarController and I want that my fifth Tab only is invisible...
is this possible??
There's no way to hide an individual tab. You could give it a blank icon, I suppose, but you'd still see the space where the tab is. If you had more than 5 tabs, you could arrange for this invisible tab to be on the More... tab item, so it wouldn't be immediately visible but the user could access it.
If you don't want the user to be able to access it, one has to wonder why you want to include it in the tab bar controller in the first place. Rememeber: when you find yourself fighting against the framework like this, there's usually a much better way to do what you're trying to do.
Not really—the tab-bar controller is pretty specifically implemented so that any view controller it manages can be accessed from the tab-bar UI somehow, be it on the bar itself or in the “More” section. What are you trying to accomplish?