Search code examples
iosxcodeuiviewcontrolleraddsubview

How to add a new custom UIViewController in IOS


I'm a new guy in this field

and i have a problem when i addSubView in AppDelegate

i have a Custom Controller look like this:

@interface mainViewController : UIViewController <UITableViewDelegate> 
{
    UITabBarController *myTad;
    UITableView *myTable;
    aModel *myModel
    // ......
}
//Some methods and @property

All i want is make a View Controller that gets other Controller also connect to the model. this is the place work all the things

and in AppDelegate i added in proper way.

[window addSubview: myController.view];
[window makeKeyAndVisible];
return YES

but its just didn't work ?

The Problem is loadView, the method i overWrite in mainViewController implement not do anythings. It's just go through

didn't i miss something?


Solution

  • You need to push your new view controller onto the stack, like so:

    [self.navigationController pushViewController:myController];