Objective-c Adding subViews in my controller

此生再无相见时 提交于 2019-12-02 05:15:51

Assuming that all of your views are part of a single screen, you don't need to add anything to your window after setting it up with your viewController. Set your viewController and then just add the next views on that controller's view.

e.g. in your AppDelegate:

[self.window addSubview:self.viewController.view];  
[self.window makeKeyAndVisible];

And then in your ViewController:

- (void)viewDidLoad {
    [super viewDidLoad];

    // blah blah blah

    [self.view addSubview:imagePickerController.view];
    [self.view addSubview:self.glView];
    [self.view addSubview:mapView];
}

Note that init methods are usually used to initialize values, and viewDidLoad is usually used to set up views.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!