views:

22

answers:

2

If I have a UIView, called " someView", than, I have a controller, which is called "myController". I want to assign the someView with myController, how can I do so in code? Thank you.

A: 

From:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

If you specify the views manually, you must implement the loadView method and use it to assign a root view object to the view property.

Read about loadView here:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/loadView

Lou Franco
+1  A: 

Basically:

Read what @Lou Franco suggests.

Implement the load view like that:

- (void)loadView {
    [super loadView];

    MyCustomView *view = [[MyCustomView alloc] initWithFrame:self.view.frame];
    self.view = view;
    [view release];

    // Setup other views if needed
}
vfn