Tuesday, April 8, 2014

About ViewController / view Controller in iPhone [ iOS ]

View Controllers are the link between data and view(visual appearance). Whenever iOS displays anything on screen it is managed by the ViewController or group of ViewControllers coordinating with each other ViewController provides the skeletal framework on which we can build our application.

iOS provides many built-in view controller classes to support standard user interface pieces, such as navigation and tab bars. You can write ur own custom view-controller.

Below image and article reference (apple website source:-http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html)



ViewController manages set of views. It provides view that can be displayed or interacted with it. Normally viewcontrollers have one root view which consists of multiple view like button, editbox etc.

Container View Controllers Manage Other View Controllers. One viewcontroller may consists of multiple view controller by forming parent-child relationship with single root viewcontroller..

We can switch to another viewcontroller from current one. Navigation controller is used for switching one view to another. Navigation controller keeps all viewcontroller in stack ways. So if displayed view is poped u will go to previous view.

A key part of any view controller’s implementation is to manage the views used to display its content. 

View-Controller manages views also they are coordinate with each other.

How View Controllers Present Other View Controllers

The view controller that did the presenting updates its presentedViewControllerproperty to point to its presented view controller. Similarly, the presented view controller updates its presentingViewControllerproperty to point back to the view controller that presented it.

 you can chain presented view controllers together, presenting new view controllers on top of other view controllers as needed.
Each view controller in a chain of presented view controllers has pointers to the other objects surrounding it in the chain. In other words, a presented view controller that presents another view controller has valid objects in both its presentingViewController andpresentedViewController properties. You can use these relationships to trace through the chain of view controllers as needed. Ex:you can remove all objects in the chain by dismissing the first presented view controller. 

When presenting a navigation controller, you always present the UINavigationController object itself, rather than presenting any of the view controllers on its navigation stack. However, individual view controllers on the navigation stack may present other view controllers, including other navigation controllers. 

Figure 10-3  Presenting navigation controllers modally

As you can see, the people picker is not presented by the photo library navigation controller but by one of the content view controllers on its navigation stack.

Listing 10-1  Presenting a view controller programmatically
/ Create the root view controller for the navigation controller
   // The new view controller configures a Cancel and Done button for the
   // navigation bar.
   RecipeAddViewController *addController = [[RecipeAddViewController alloc]
                       init];
 
   // Configure the RecipeAddViewController. In this case, it reports any
   // changes to a custom delegate object.
   addController.delegate = self;
 
   // Create the navigation controller and present it.
   UINavigationController *navigationController = [[UINavigationController alloc]
                             initWithRootViewController:addController];
   [self presentViewController:navigationController animated:YES completion: nil];






0 comments:

Post a Comment

About

Powered by Blogger.