ChildViewController image enters and then disappears

I have a view controller in which there is a button and a window.

When you click a button, the view in the window should change.

A view in a window is another ViewController and its view.

When you press the start button all the methods viewDidLoad, viewWillAppear, viewDidAppear.

However, after the launch, the viewDidAppearview disappears, without launching viewWillDisappearandviewDidDisappear

The view appears within a second before this happens, and all its elements will be initialized, if I pause execution using the debug window and po any of the user interface elements, they are not null.

Why can this happen?

Here is my code to add a view:

    if(![self.childViewControllers containsObject:_detailsContainer]){

    _detailsContainer.view.frame = self.scrollView.bounds;
    [_detailsContainer willMoveToParentViewController:self];
    [self addChildViewController:_detailsContainer];
    UIViewController *currentViewController = [_mainSource viewControllerForContentAtIndex:self.pageIndex];
    [self transitionFromViewController:currentViewController toViewController:_detailsContainer duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:NULL completion:^(BOOL finished){

     [_detailsContainer didMoveToParentViewController:self];

    }];
}

Here is my controller viewWillAppearand viewDidAppearchild view:

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if(self.isEditingDetails){
        [self setUserDetails:[self.userSettings getUserDetails]];
    }

}

-(void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];
    LogInfo(@"details view did appear");

}
+4
1

, - UIViewController.

[self addChildViewController:_detailsContainer] [_detailsConter willMoveToParentViewController:self]. [currentViewController willMoveToParentViewController:nil] .

[currentViewController removeFromParentViewController] .

. , transitionFromViewController... FromViewController: toViewController: : : : :

0

Source: https://habr.com/ru/post/1538593/


All Articles