Objective-c Adding subViews in my controller

后端 未结 1 792
醉酒成梦
醉酒成梦 2021-01-23 12:17

I have an aplication with the delegate, the controller and some other things. The thing is that i initzialize everything in the controller with init. This init creates 3 UIVIews

相关标签:
1条回答
  • 2021-01-23 12:56

    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.

    0 讨论(0)
提交回复
热议问题