Can not add a ChildViewController in Current Controller

ios objective-c childviewcontroller

41 просмотра

1 ответ

I took 2 UIViewController HomeView and ViewMyStuff in Storyboard.

I am adding ViewMyStuff Controller in HomeView. In HomeView's ViewDidLoad, written below in my code.

- (void)viewDidLoad
{
    ViewMyStuff *vwMyStuff = [self.storyboard   instantiateViewControllerWithIdentifier:@"viewreportvc"];
    [self addChildViewController: vwMyStuff];
    [vwMyStuff didMoveToParentViewController:self];
}

vwMyStuff controller is not added in HomeViewController. Is there anything I missing? Please help

Thanks.

Источник Размещён: 08.11.2019 11:13

Ответы (1)


0 плюса

Решение

You need to add subView of your ViewMyStuff *vwMyStuff viewController.

- (void)viewDidLoad
    {
        ViewMyStuff *vwMyStuff = [self.storyboard   instantiateViewControllerWithIdentifier:@"viewreportvc"];
        [self addChildViewController: vwMyStuff];
        [vwMyStuff didMoveToParentViewController: self];
        [self.view addSubview:vwMyStuff.view];
    }

Hope it works for you!!

Автор: Ravi B Размещён: 20.08.2016 11:31
Вопросы из категории :
32x32