iphone - UIViewController -


My question is: I do not think we can create a visual controller with a Nib file and we can do it without Any nib file I mean: For example, anyone tells me about a template, navigation based app, how does it work, the first object is done?

Thank you for your reply

The only way to instantiate a UIViewControler is to : - (id) initWithNibName: (NSString *) nibName bundle: (NSBundle *) nibBundle

Which means that you "normally" The .nib file is called to load ...

But you have both the "nib" parameters: code> myUIViewController = [[MyUIViewController alloc] initWithNibName: zero bundle: Zero];

... If you want to directly load it and want to manage it by yourself, you usually crimp a sub-section of UIViewController (MyUIViewController in my sample) And in its @NovNi you apply the method loadView

where you must create a view of your class

  - (zero) load view {UIView * aUIView = [[UIView Alloc] initWithFrame: CGRectMake (0.0, 0.0, 320, 480)]; Self.view = aUIView; AUIView.backgroundColor = [UIColor colorWithRed: Green 2.3: .3 blue: .5 alpha: 1]; // aUIView ... if necessary, set other properties ... [aUIView release]; }   

In this way you can manage it without ".nib file", by adding all objects and subviews only via code ...

Comments