popToRootViewControllerAnimated not working correctly

故事扮演 提交于 2020-01-03 16:56:37

问题


I have a navigation app and when certain errors occur I want to dump the user back on the view they started on so I have the following code execute in those conditions:

[self.navigationController popToRootViewControllerAnimated:YES];

When it executes the root view isn't always displayed and/or the navigation bar will have the wrong title. Sometimes the navigation bar will even have the back button showing on it and how could that be on what's supposed to be the root view?

I tried using NO for the animated parameter and that didn't help.

I also moved logic from viewDidLoad into viewWillAppear in the root controller since I originally set the title in there, and other things, and that didn't help either. The title for the navigation bar was still always wrong and still had a back button displayed on it.

I'd appreciate some constructive suggestions. FYI, I'm running 3.1.2.


回答1:


Not sure if it's the same thing but I've found that if you try to popToRoot without a significant time lag from the intial push of the one or more viewcontrollers the apps can't handle it. I was lucky in that I had reason to put in a fake waiting window in my app with a 2 second delay. With the delay in place the same popToRoot code worked fine.



来源:https://stackoverflow.com/questions/1604374/poptorootviewcontrolleranimated-not-working-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!