tabBarController unLoad itself after call modalView

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:54:53

问题


I have tabBarController with 6 views. As default tabBarController load first view, I need to load view #6 at my application start, so in my tabBarController I add to viewWillAppear [self.tabBarController setSelectedIndex:6];, ok. In my view #3 a have 2 modal views witch I create in storyboard. When I tap a button I load my modal view, and when a close it [self dismissModalViewControllerAnimated:YES]; (I was in view #3) I see view #6, but I need to come back to view #3, so if I understand right when I call my modalView it unload my tabBarController and when I close it load tabBarController again with view #6, but i need to see my view #6 where i call my modalView, how can I fix it?

P.S. I hope you understand my English


回答1:


It looks like You added [self.tabBarController setSelectedIndex:6]; to viewWillAppear instead of viewDidLoad. There is no viewWillLoad there.




回答2:


Do something like this in the viewDidAppear method of your tab bar controller, so it only sets the selectedIndex when the app starts up:

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    static BOOL isFirst = YES;
    if (isFirst) {
        [self setSelectedIndex:6];
        isFirst = NO;
    }
}



回答3:


I change order of items in my tabBarController in storyboard, change numbers of views in code and everything works. Thanks to all.



来源:https://stackoverflow.com/questions/19742416/tabbarcontroller-unload-itself-after-call-modalview

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