View hierarchy of UIViewController - objective-c

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.

Related

Navigation Buttons + UICollectionview on same controller?

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.

UIPickerView UIScrolling with view

I have a UIPickerView on a scrollable view with multiple buttons and textfields. UIPickerView picks values into two of the text fields. Now, the problem is UIPickerView is also scrolling along with the page. Can any one guide me how to keep the UIPickerView at the bottom and opaque on a scrollable page?
You need to add the UIPickerView to the superview of the UIScrollView (possibly the view property of the UIViewController that you're working in.
You might also want to extend the contentSize property of the scroll view by the height of the picker view so that all objects in the scroll view can be scrolled on screen and aren't hidden under the picker view.
Take another View on the top of the scroll view and put your UIPickerView into that so it is now independent to your UIScrollView like this:

Selection of UITabBarItem loading corresponding view

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.

UIView controller containing toolbar and UITabBarController

I'm currently creating an ipad application.
the idea is to have a toolbar at the top and a tabbar at the bottom.
The toolbar has to be visible on all tabs, so it won't disappear.
I was thinking about having a UIViewController as the main view and put the tool bar in there.
Then adding the uitabbarcontroller to that main view controller, but i'm not sure how to do that.
At the moment i have my tabbarcontroller as the main view and added the toolbar to every tab.
Can anyone help?
Thanks
The Tab Bar Controller should be at the root. What you can do is create a method that returns a propertly configured toolbar & add it to each of the view controller's viewDidLoad (either by using a category method, inheriting a common UIViewController subclass, or simply via a C-style factory method.
This way your hierarchy isn't flipped, and the tab bar is at the root like it should be.

UINavgationController and UITabBarController together

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.