0
我的应用程序是一个基于标签的应用程序,在一些标签中有导航控制器。标签导航控制器,在第一个视图中启动
如果我导航视图,当我在第二视图(导航)我和更改选项卡,当我再次单击该选项卡,它开始于第二种观点,因为我完了。
所以,我想要的,是改变标签时,该
popToRootViewControllerAnimated:
效果。所以,我会始终从第一个视角开始。
我该怎么做?
谢谢!
我添加一些代码到我的项目下列巴特怀特利的回答,我的MainTab.h:
#import <UIKit/UIKit.h>
@interface MainTab : UITabBarController <UITabBarControllerDelegate,UITabBarDelegate>
@end
MainTab.m:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"this class is loaded");
self.tabBarController.delegate = (id)self;
[self setDelegate:self];
}
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSLog(@"changing tab");
if ([viewController isKindOfClass:[UINavigationController class]]) {
[(UINavigationController*)viewController popToRootViewControllerAnimated:YES];
}
}
解决了!我编辑我的帖子与代码
谢谢!
而不是与解决方案的编辑你的问题,添加其他答案,详细描述它,所以它更容易找到 - 和保持的问题分开从答案。 =) –