viewWillDisappear和viewDidDisappear之间的延迟很大

时间:2013-03-16 18:06:06

标签: iphone cocoa-touch ios6

这是日志输出

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

viewWillDisappearviewDidDisappear之间,这是一个很酷的30秒。还有什么事发生在那里?

1 个答案:

答案 0 :(得分:1)

这里的问题是线程。这是因为此操作是在AFNetworking代码的回调中。而不是使用:

[controller.navigationController popViewControllerAnimated:NO];

需要:

// 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];
});