I have a UIViewController named "RootViewController" which contains a UITableView and a UITabBar (2 TabBarItems - Favorites and More).
When the View is being displayed, the TableView and TabBar are visible. Now I want to load an additional view when pressing the other TabBarItem (More). And backwards, but the tabbar should be available. (User can press Favorites)
How can this be done?
BR,
mybecks
If you want the UITabBar to be visible on more than one screen you should use a UITabBarController. That controller should hold your different UIViewController.
It's wheel explain in the documentation on how to implement that controller.
Related
I'm newbie with iOS and asking for direction.
I want to make a page which contains navigation buttons on top and when tap load different UICollectionView's as you can see on the app screen taken from "Fancy". Also buttons line have to be fixed on top while scrolling down. (just like in the screenshot)
Which is the right approach?
Base class to be UICollectionViewController and adding as SubView
Using UIScrollViewController?
etc...
Thanks in advance.
Base class should be UiViewController implementing UICollectionViewDelegate
UIViewController <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
Create different NSArray for each Category of your project as datasource of UICollectionView
use UISegmentedControl for switching the datasource of UICollectionView and reload UICollectionView to display different content.
You can customise your Segmented Control as you wanted.
Implement UITabbarController for the bottom bar to enter any other views
There are a number of ways to go about this. The simplest would probably be to use a UIViewController subclass whose view contains a UISegmentedControl subview (for the navigation controls) and a UICollectionView subview for the content.
In my ContainerViewController i added scrollView as a subview.And in that scrollview i added ImageViewController's view as a subview. Now should i add the ImageViewController as a child view controller to the ContainerViewController?
There is no concept for "child view controller". You only need to set the hierarchy for the views, and let the view controllers control the view's behavior.
you don't need to add the UIImageView again for the basic UIViewController.
hierarchically, you created the first UIViewController and for its UIView you added the UIScrollView as a subview, and you added an UIImageView to the UIScrollView.
this is perfect.
try to imagine them as a pair of shoes (UIImageView) in a box (UIScrollView) what is in your drawer (UIViewController).
you won't need to put the pair of shoes into your drawer again if you put the box with the shoes into the drawer before; because your pair of shoes are already in the drawer, inside a box.
I have a UITabBarController which is the second item inside a UINavigationController.
Each item within the UITabBarController is a sub class of UIViewController. How can I create a button that appears at the top right of the navigationBar and changes depending on which tab is selected.
I am using storyboards, just in case there is a gui way of achieving this.
Implement the UITabBarControllerDelegate method tabBarController:didSelectViewController: and then depending on what view controller was selected set the rightBarButtonItem of your UINavigationController to show whatever you want it to show.
I am trying to create a view with a TableView in the center, NavigationBar on top, and a TabBar with 5 items. The TabBarItems will be attached to 5 different modal views. And the tableview can select an item and "navigate" to another tableview or detail view.
Following the Apple doc, I tried to create a NavigationController in a TabBarController in IB, but failed. I read all the posting regarding to this topic, and they all described a NavigationController inside one of the TabBarItem. But that is not what I want. The TabBarController and NavigationController are separate controller doing separate thing in the same view.
So I start wondering maybe it is a design issue. I should just use a NavigationController and add the TabBar as objects and not controller in the view.
Am I going the right track or is there a better way to combine NavigationController and TabBarController in IB to do the job that I want. Am I making sense?
If the tab bar is actually being used as a tab bar, it sounds like you want 5 navigation controllers, one for each tab.
If the tab bar is being used as a toolbar to hold buttons that bring up modal view controllers, push views onto the navigation controller, or other actions besides what a tab bar is intended for, use a UIToolbar instead. UINavigationController actually has toolbar support built in, just set its toolbarHidden property to NO and set the toolbarItems property on each view controller that can go inside the navigation controller to an array of appropriate UIBarButtonItems.
In have a UITabBarController with 3 view controller subviews.
The default subview for the app is viewOne (with viewControllerOne). The other two are viewTwo and viewThree with the ordering in the UITabBar as expected.
My objective is to have an action be done when viewTwo is selected in the UITabBar while viewOne is active.
The viewTwo view is never shown but instead, when viewTwo is selected, an action is performed in viewTwoController, the UITabBar then shows viewOne as selected and the orignal view is shown again.
The UITabBarItem in the second slot must remain associated with the viewTwo nib.
Is it possible to associated a UITabBarItem with an action in its view controller and upon finishing that action, instruct its parent UITabBarController to switch to a different view?
UITabBarControllerDelegate got a method called tabBarController:shouldSelectViewController that you can override to do whatever you want to do when a tab switch has been triggered.
Here is the documentation: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITabBarControllerDelegate/tabBarController:shouldSelectViewController: