William Entriken
William Entriken

Reputation: 39273

Huge delay between viewWillDisappear and viewDidDisappear

Here is the log output

2013-03-16 14:02:59.301 Echo[65406:4503] child viewWillDisappear start
2013-03-16 14:02:59.303 Echo[65406:4503] child viewWillDisappear returning
2013-03-16 14:02:59.303 Echo[65406:4503] parent viewWillAppear start
2013-03-16 14:02:59.305 Echo[65406:4503] parent viewWillAppear returning
2013-03-16 14:02:59.307 Echo[65406:4503] parent finished calling popToRootViewControllerAnimated on child.navigationController
2013-03-16 14:03:30.120 Echo[65406:c07] child viewDidDisappear start
2013-03-16 14:03:30.121 Echo[65406:c07] child viewDidDisappear returning
2013-03-16 14:03:30.121 Echo[65406:c07] parent viewDidAppear start
2013-03-16 14:03:30.122 Echo[65406:c07] parent viewDidAppear returning

That's a cool 30 seconds between viewWillDisappear and viewDidDisappear. What else is going on in between there?

Upvotes: 2

Views: 551

Answers (1)

William Entriken
William Entriken

Reputation: 39273

The problem here was threads. It is because this action was in a callback from AFNetworking code. Instead of using:

[controller.navigationController popViewControllerAnimated:NO];

Needed:

// http://stackoverflow.com/questions/9411271/how-to-perform-uikit-call-on-mainthread-from-inside-a-block
dispatch_async(dispatch_get_main_queue(), ^{
    [controller.navigationController popViewControllerAnimated:NO];
    [self.navigationController pushViewController:newController animated:YES];
});

Upvotes: 1

Related Questions