pls help me to understand the conception of UiView and UIViewController, i know that it works like mvc pattern, and as i understand UIView is a visual representation of View and controller is responsible for this view right? and when we create an instance of viewcontroller with initwithnibname we programatically attach some view to some controller , in other words we say the controller that he is responsible for drawing this view yes?
if we do not init it with nib nae, does it find the nib automatically or not?
this attachment also possible through Interface builder , am i right?
but what about presentModalViewController function? he get the viewcontroller parameter and display the view or i don’t understand the meaning of it ? and also is it possible to make a view without xib file, only in viewcontroller and after show it ?
A single view controller is generally responsible for an entire hierarchy of views. A view controller manages a “screenful,” or at least an area, of related content.
No — a view should know how to draw itself. A view controller might tell the view what to draw, but the view needs to know how to render that into the current graphics context.
It can. If you pass nil for the nib name and bundle, UIViewController will try to find a nib matching the name of the view controller’s class. You can, however, override
-loadViewto create your own views programmatically if you prefer to do that.A view controller presented modally is still responsible for its view hierarchy.
-presentModalViewController:really deals with the relationship between view controllers — how the view controller’s view is moved onto the screen, and what happens when it’s done.Yes, you can certainly do that if you want to. Every view has an
-initWithFrame:initializer that you can use to initialize a view, although some views provide other options. For example, UIButton has a+buttonWithType:method that you can use to create a button.