views:

36

answers:

1

The following code is in my "switchviewcontroller.m" file

- (void)viewDidLoad {

    MainView *mainController=[[MainView alloc]
                                        initWithNibName:@"Blue View" bundle:nil];

    self.mainViewController=mainController;
    [self.view  insertSubview: mainController atIndex:0];
    [mainController release];


    [super viewDidLoad];
}

All I am trying to do here is load this view "main" into the view in my mainwindow.

The code just gives a warning and compiles, but when it executes it crashes on the line in warning

//80: warning: incompatible Objective-C types 'struct MainView *', expected 'struct UIView *' when //passing argument 1 of 'insertSubview:atIndex:' from distinct Objective-C type
[self.view  insertSubview: mainController atIndex:0];
+1  A: 

I believe you are trying to insert a UIViewController, not a UIView as insertSubview is expecting.

Try this:

[self.view  insertSubview: mainController.view atIndex:0];
Jacob Relkin