开发者

Stuck on child view when you go back to the view controller via the tab bar

开发者 https://www.devze.com 2023-04-04 12:43 出处:网络
So here the deal. I have an iphone app and on of our views on the tab bar, refer to this tabbar item as \"tabbar1\", it pushes you through a couple other views without a tabbar(not the problem). At th

So here the deal. I have an iphone app and on of our views on the tab bar, refer to this tabbar item as "tabbar1", it pushes you through a couple other views without a tabbar(not the problem). At the last view you go to, instead of having a back button we have done button that uses this code:

[self.tabBarController setSelectedIndex:0];

once you go to the root tabbar item (which works fine). The problem is when you go back to the the tabbar1 and you end up on a view with no tabbar and the only option is to press the done button and go ba开发者_StackOverflow社区ck to the root tabbar item. This is definitely a loop.

How would I correctly fix this? with either the way to switch to the root tabbar item or to reset tabbar1?

Much appreciated for any response.


I assume you're using a UINavigationController to 'push through' the view controllers in tabbar1. Before calling [self.tabBarController setSelectedIndex:0]; you should pop all the view controllers that are on the UINavigationController's stack:

[self.navigationController popToRootViewControllerAnimated:NO];
[self.tabBarController setSelectedIndex:0];
0

精彩评论

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