开发者

self.navigationcontroller pushs viewcontroller without navigation item

I am running out of ideas with this problem. I have a UITabbarcontroller and 2 Tabs with Navigationcontrollers in there.

I have a set of ViewControllers for the navigation. These ViewControllers are used in the same order on both tabs/navigationcontrollers with slightly different data.

The previous-to-last Viewcontroller is making a NSURLConnection, and in connectionDidFinishLoading: the last viewcontroller should be shown, using this code:

[self.navigationController popToRootViewControllerAnimated:NO];
[self.navigationController pushViewControll开发者_Python百科er:lastViewController animated:YES];

This will pop to the root viewcontroller, but will never push the last ViewController. (Sidenote: This was actually working for quite some time, but stopped working when using this also from the second tabbar's navigationcontroller).

Furthermore, if I comment out the first line:

//[self.navigationController popToRootViewControllerAnimated:NO];
[self.navigationController pushViewController:lastViewController animated:YES];

The last viewcontroller is shown, but misses the back button in the navigation bar, and it's not disabled or something. I suspect that somehow self.navigationcontroller is returning the wrong navigationcontroller. It's as if the navigationcontroller has "forgotten" about the viewcontroller stack.

  1. Could this be related to connectionDidFinishLoading: being a different thread?
  2. Has someone a suggestion how to get "the navigationcontroller in this tab" in a different way?

I triple checked the code up and down, I couldn't find anything. The other viewcontrollers before this one are being pushed and popped without any problems.

Thanks for any help on this, I feel stuck!


What you said gave me an idea. I was thinking that self.navigationController may be set to nil after it's pushed, therefore, it's not set when you're pushing the new view controller. Doing this fixed the problem! :)

UINavigationController *navigationController = self.navigationController;
[navigationController popToRootViewControllerAnimated:NO];
[navigationController pushViewController:lastViewController animated:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜