I'm using a tab bar view controller with more than 5 items and it's showing as the fifth item an item named "More". I want to avoid that item and make the scrollable tab bar.
ThanksImage
I don't think you can subclass UITabBar and get what you want.
You probably need to create this as a custom UI object. You could create it using a UIScrollview.
If you are a beginner then this is likely over your head.
I know this is old but maybe you could add a UIView to a Tab Bar Controllers scene (not the actual controller) and then add a UICollectionView on top of that same UIView of yours to create a custom Tab Bar. You would have to change the size and flow layout for the collection view but other than that if you are familiar with switch statements and delegates I don't see why it couldn't work!
Related
Here is a photo, I need to make this when you click on the right button it is moving you forward and backward for the left one.
Here is the result I want:
The buttons moves you to a different views
I think you can create a view and add label for title also page controller too after that add collection view under view and enable pagination. Use custom nib file for views (screens).
I'm making an app with interface builder using storyboarding.
I want to have a tab bar where no item is selected. This can be accomplished by setting
TabBar.SelectedItem = null;
But if you try to do that, you get the following error:
'Directly modifying a tab bar managed by a tab bar controller is not allowed.'
So I can't use the standard UITabBarController. I've created a custom UIViewController, and added a UITabBar. Switching between tabs is working fine, and having no selection is also working as it should.
But I have no idea how to show my other view controllers from my custom view controller with the tab bar. Remember that I'm using interfacebuilder, so I can't just create my view controllers in code as new objects and add them to the view. (as suggested in UITabBar funcionality without UITabBarController)
So how do I show my own views without using the UITabBarViewController?
Edit: Still haven't found a solution, but I did a hacky fix. Simple create an other tab bar and place it on top of the original tab bar. Listen to those events and use SelectedIndex to change the view displayed. Then add some function that will select / deselect the items on your own tab bar.
In fact, even if you design your others UIViewControllers from IB, you can instantiate them from code. You'll probably have to play a bit with frame and autoresizing properties to make them fit the part of your main view you want them to display inside, but it's possible.
So, knowing that, a simple solution is to create a simple UIView (we'll call it 'tabFrame') in your main UIViewController, which fill the screen from the top of your UITabBar to the top of the screen; instantiate the UIViewController corresponding to your tabs and add their view as subview of tabFrame. Now you just have to catch item selection from tabbar to hide or show the desired subviews.
Hope I'm clear enough, else don't hesitate to question!
EDIT: pointed out this morning that in storyboarding context, you can effectively instantiate viewControllers / scene from code, but for not loosing designer settings it must NOT be done through directly calling their constructors, but through StoryBoard.InstantiateViewController("vc_identifier") calls, after having set identifiers to VCs in storyboard editor.
See http://docs.xamarin.com/ios/recipes/General/Storyboard/Storyboard_a_TableView for example
I want to build an application with this kind of navigation between views:
a scrollview with text items (like a menu bar). Check Radio-Canada app on app store (free).
How to proceed? I know that I need a scrollview, but after that... You have to understand that I don't have too much experience with iOS 5.
Check this snapshot for an example:
snap http://www.eazyrf.com/Snap2.jpg
For a horizontal scrollview, just create a scrollview and add buttons to it. The white 'selected' background you clipped can be created by loading a white oval and using resizeableImageWithCapInsets: to extend it to fit the text. Link the button's click event to a function that presents the new view. If this 'menu bar' acts like a standard iOS tab bar, you'll need to manage the view hierarchy yourself.
For a vertical scrollview, most likely you're looking at a UITableView contained within a UINavigationController, where the class implementing UITableViewDelegate for the table view is responding to didSelectRowAtIndexPath by pushing a new view onto the navigation controller. This is a common pattern to implement what looks like a scrolling list of items, where tapping on one cell causes a transition to a new screen.
I am trying to build a screen like this:
I've already built the navigationItem (the "title Bar") and the table view, now I'm looking for a way to add the buttons under the table view.
The result should look similar to a tab bar, but as the buttons are used to influence the the number of displayed records in the table, I'm only dealing with one controller.
How do I achieve what I'm looking for?
I can think of two ways off the top of my head you could accomplish something like this.
You could create a UISegmentedControl and place it in your tableview's tableFooterView property. The buttons would only be visible underneath the tableview and would scroll with the table.
You could create a UIToolbar, or ideally display the toolbar you get for free with the navigation controller, and place a UISegmentedControl there. This way the buttons would always be visible regardless of where the user has scrolled to.
Hope this gets you started.
A couple of approaches suggest themselves:
1) You could use an actual tab bar. If you do that, your outermost view controller has to be the UITabBarController. Some searching on "UITableView inside UITabBar" and the like should give you more details.
2) Set the frame of the UITableView to be less than the whole screen. Have both it and the buttons (which might well be a UISegmentedControl) be subviews of a common container.
I have this problem, I've got a navigation-based application, and on the one of the detail view i need to have UITabBar, which will display some UITableViews. Since apple documentation says "you should never add a tab bar controller to a navigation controller" it make quite a problem, i've found this sample: link text, it's working, but after picking one of the table view, the UITabBar disappears.
don't use a tab bar controller, just use a UITabBar inside your controller view and manage the switches between UITableViews yourself, either by:
loading up as many table views as you
need and stacking them (bringing the
one corresponding to the tab bar hit
to front)
switching a single table view's data
source and delegate among a few
helper objects - one per tab in your
bar. When the user clicks a tab, reset the single table view's data source then instruct it to reloadData
Now that you are not using a TabBarController for showing the tableviews (as mentioned in the link), have you made sure that the table views or any other views you are adding when a tab is tapped are correct size?
You are adding a subview or bringing it to top so the table view is probably covering your tab bar.
When they are choosing an item from your table view are you pushing a new view controller onto your navigation controller? If so, you will leave the tab bar behind!
Without some hefty hacking, you generally can't do what you're trying to do. What you'd have to do instead is to deal with adding new views yourself when a table cell is selected so the new views you add don't overlap the tab bar at the bottom. Though this will probably break the navigation controller.
Though my advice is to rethink that part of the app's ui so you don't care that the tab bar vanishes. Sorry :(