Layout spins up when I click multiple controllers without animation

So, I have a stack of three UITableViewControllers, each of which correctly displays its view under the navigation bar when I manually click on the user interface.

However, now I am working on restoring the state through reloading the application, and therefore I push the same two controllers on top of the root view controller, one for the same method in the main thread. As a result, the view of the middle controller is too far lowered, and the top view of the controller is too far (under the navigation bar).

Relevant Code:

for (int i = 0; i < [controllerState count]-1; i++) {
    MyViewController* top = (MyViewController*)navigationController.topViewController;
    int key = [[controllerState objectAtIndex:i] integerValue];
    [top restoreNextViewController:key]; // this calls pushViewController: 
    // so top will be different in the next iteration
}   

I suspect the problem is that I do not allow some important process of updating the user interface between two clicks, because they occur on the same thread. It seems that automatic view adjustment, which should affect the top controller, instead affects the middle one.

It is right? And if so, what should I do, since I want all state recovery to happen immediately after the application starts?

EDIT: , . restoreNextViewController: - MyViewController, , [self.navigationController pushViewController:foo animated:NO]. , , , 6 , . , , . , ; ?

; .

+3
4

viewWillAppear:.

0

, viewWillAppear:? isRestoringState appDelegate , viewWillAppear:, , , . - :

- (void)viewWillAppear:(BOOL)animated {
    if ([[UIApplication sharedApplication] isRestoringState]) {
        // restore local state, set myChildController if a child is visible
        if (myChildController) {
            [self.navigationController pushViewController:myChildController animated:NO];
        }
    }
}
+1

pushViewController: : . -restoreNextViewController. , , . Nav? .

0

, UINavigationController, . UINavigtionController , , .

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

, , , ViewController , , NavigationController.

UIViewController *myViewController = [[UIViewController alloc] initWithNibName:@"myView" bundle:nil];
[navigationController pushViewController:myViewController animated:NO];

, "" UIViewController, "" .

- (UIViewController *)popViewControllerAnimated:(BOOL)animated

eg [[self navigationController] popViewControllerAnimated:NO];

, , push/pop . , . .

0

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


All Articles