views:

80

answers:

1

I have a view called MyViewController, that I initialize from a xib file.

Its loadView method looks like this:

- (void) loadView
{
    [super loadView];
    // some initializations
}

I create it from some other view controller like this

-(void) createMyViewController
{
        MyViewController *aController = [[MyViewController alloc] initWithNibName: @"MyViewController" bundle: nil ];
        self.myController = aController;
        [aController release];

    CGRect rect = CGRectMake(10, 232, 308, 176);
    myController.view.frame = rect;
    myController.view.autoresizingMask = 
    UIViewAutoresizingFlexibleWidth | 
    UIViewAutoresizingFlexibleHeight |
    UIViewAutoresizingFlexibleTopMargin |
    UIViewAutoresizingFlexibleBottomMargin;

    [self.view addSubview:graphController.view];

}

I've noticed, that each time .view notation is called, loadView of MyViewController is called. I set the view property in the xib file, whether File Owner identity is set MyViewController and the view identity is set to MyView. When the view is set it doesn't suppose to call loadView each time.

Please shed some light! I'm fighting this for the whole day already...

Thanks a lot

+1  A: 

If you're creating the view in a nib file, you should be using viewDidLoad, not loadView.

Rob Lourens
tried, this is not being called for some reason... How come? :(
Nava Carmon
ok, when I added MyView to a UIView and created a special outlet for myView it started working properly.
Nava Carmon