tabBarController在调用modalView后取消自己的加载
我有tabBarController 6视图。 作为默认tabBarController加载第一视图,我需要加载视图#6在我的应用程序启动,所以在我的tabBarController我添加到viewWillAppear
[self.tabBarController setSelectedIndex:6];
, 好。 在我看来,#3有2个模式的意见,我创造了故事板。 当我点击一个button,我加载我的模态视图,当一个closures它[self dismissModalViewControllerAnimated:YES]
; (我在视图#3)我看到视图#6,但我需要回来查看#3,所以如果我明白当我打电话给我的modalView它卸载我的tabBarController,当我closures它再加载tabBarController与视图# 6,但我需要看我的视图#6,我打电话给我的modalView,我该如何解决它?
PS我希望你能理解我的英语
它看起来像你加了[self.tabBarController setSelectedIndex:6];
viewWillAppear
而不是viewDidLoad
。 那里没有viewWillLoad。
在你的标签栏控制器的viewDidAppear方法中做这样的事情,所以它只在应用程序启动时设置selectedIndex:
-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; static BOOL isFirst = YES; if (isFirst) { [self setSelectedIndex:6]; isFirst = NO; } }
我更改故事板的tabBarController中的项目顺序,更改代码中的视图数量,一切正常。 谢谢大家。