disable rearrange the tabs iphone - objective-c

I have a six UITabBarItem in a UITabBarController.
I want to disable the NavigationBar that auto-generates the tab number 5, which allows you to reorder the tabs as you want.
Is there a way to disable this function?
EXTRA
I use customtabbar but in the tab5 appears this navigationbar.
the tab6 for me must be "hidden"

there is the property customizableViewControllers
from the docs:
"Changing the value of the viewControllers property (either directly or using the setViewControllers:animated: method) also changes the value of this property. When first assigned to the tab bar controller, all view controllers are customizable by default."
so call myTabBarController.customizableViewControllers = nil to remove customization

It looks like you are using a UITabBarController.
You can only have up to 5 tab bar items without bringing up the additional item to customize the bar items. If you don't want the extra tab to allow for customization, your 6th item will be unreachable anyway, so just remove the last tab to make it 5 items.
From the UITabBarController Documentation:
The tab bar has limited space for displaying your custom items. If you
add six or more custom view controllers to a tab bar controller, the
tab bar controller displays only the first four items plus the
standard More item on the tab bar. Tapping the More item brings up a
standard interface for selecting the remaining items.
If you do not like this limitation, use a UITabBar directly. There is more work involved because you won't be using a UITabBarController which manages the view controllers of your tabs for you.

Related

Adding Navigation Item in UIViewController

I'm trying to add UINavigationItem to my UIViewController as mentioned this answer. However the Navigation bar is not showing in my view. I tried even adding an outlet and setting the title programmatically and also adding the NavigationItem in two different places. Still it doesn't show. This view controller is embedded in a TabBarController. WHat am I missing here?
Thanks is advance.
This view controller is embedded in a TabBarController
But is it embedded, first and foremost, in a UINavigationController? If not, there will be no navigation bar that automatically appears and that automatically uses your view controller's navigation item.
If you don't want to use a UINavigationController (because you have no navigation to do), then you can add a navigation bar manually. But in that case your view controller's navigation item will not be used automatically to populate the navigation bar; you must populate it manually.
Typically, people do use a UINavigationController, even if there is no navigation to do, just to get this automatic behavior - to show the navigation bar and to populate it automatically.
[NOTE: The fact that you have told Interface Builder to show a navigation bar for this view controller, as if it were in a navigation controller, is irrelevant; that won't cause you to get any navigation bar when the app runs.]

How I can keep the value of a barButton among the views handled by a tab bar?

I have two weeks programing in objective-c. Basically, I have a three views handled by a tab bar. Each view has rounded rect buttons that calls another view with different information. Also, at the top of each view, there is a bar button item. The title of all those bar button items depends of the value of a switch: manual or automatic. If it is automatic, the button's title must be "Trigger". If it is manueal, the button's title must be "Star" and, if you make a click on it must change to "Stop". My problem is, the button's title is changing but if I'm in the fist view and I press "start", it change to "stop", but in the second view it's still "start".
So, could you help me with this, please?
Sorry, I don't understand your problem (it would be easier if you would provide code or pictures). Thus I try to interpret the title of your question:
You have a tab bar controller that controls a few view controllers that have each its own view. These views are independent of each other. If each view has e.g. its own barBottom item but they should all have the same title when you switch from one tab view to another, their titles must be changed by program. Since only the tab bar controller knows when it changes its views, it has to assign the new title to all the barBottom items of its views.
It can do this using its delegate that corresponds to the UITabBarControllerDelegate protocol. This delegate (and the tab bar controller may be its own delegate) can e.g. implement the method tabBarController:didSelectViewController: which is called when one switches from one view to another. In this method, the tab bar controller can set the new title by calling a method in each of its view controllers (which can be accessed via the property viewControllers).

UITabController with shared title bar for all tab view items

When my app launches, I'll have an initial list that the user chooses from. Once chosen, the user should be taken to a UITabController that has content related to the item chosen on the initial list.
For the user to get back to that list, I'd like to have a Title/Tool bar at the top of the app. The bar should contain a title and a button that let's the user get back to that first modal list of items where a new item can be chosen.
I know I can have each individual view controller specify a title as well as a button, but I'd like it controlled at the AppDelegate rather than at each view so that each view doesn't have to contain duplicate logic to accomplish this.
Ideally my app would be a UINavigationController with a UIViewController that contains a UITabViewController; however, it seems that Apple frowns on this type of flow.
Is there a way to manage this?
I don't think there's any way to do this at the tab bar controller level. You could make a subclass of UIViewController to add some methods and properties to take care of your title bar, and then have each of your individual controllers inherit from that class instead of directly from UIViewController

How to determine the current active view in tabbarcontroller

I have a tab bar with three tabs. In one of the viewcontrollers belong to the middle tab, my code needed to determine if the active view is the first viewcontroller's view. Any idea?
You can tell which view controller is the active one by calling the selectedViewController property of your app's UITabBarController(documentation linked for you).
There's also a selectedIndex property as well.

Problem tabbing to field when adding and removing view

I have an scope bar containing a NSSearchField. The bar can be shown and hidden using a menu item. I generate this bar by creating a new NSViewController (and loading a new view from the XIB). When the bar is shown, I do a addSubview: to the window's contentView; when the bar is hidden, I do removeFromSuperview to the view within the view controller.
If when I launch the app and the bar is already opened, hitting tab toggles between the main view within the window (a table view) and the search field in the scope bar. If I launch the app and the bar isn't already shown, once I do show the bar I can tab from the table view to the search field, but not the other way.
Once I remove the scope bar for the first time, then show it again, I can no longer tab between the search field and the table view, no matter which view is currently selected.
Is there something I need to be doing besides addSubview: and removeFromSuperview? I can't wrap my head around why this won't work, and especially why I get different behaviors if the bar is shown on launch or not.
You need to set the nextKeyView of both views if you want to control what happens when you hit the tab key.
[yourTableView setNextKeyView:yourSearchField];
[yourSearchField setNextKeyView:yourTableView];
However, you need to be careful because you can break the automatically constructed key-view loop. This article has more detail on how to handle this situation.
I was able to get the desired behavior by setting setAutorecalculatesKeyViewLoop: to true on the views' window.