tabBarController unLoad itself after call modalView
Asked Answered
N

3

0

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

Nave answered 2/11, 2013 at 13:33 Comment(2)
Your understanding is incorrect -- the tab bar controller is not unloaded when you present a modal controller.Kernan
@Kernan incorrect, but viewWillAppear works after modalView closes. How to fix it?Nave
N
0

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

Nave answered 6/11, 2013 at 14:6 Comment(0)
W
0

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

Wound answered 2/11, 2013 at 14:55 Comment(1)
if i put it in viewDidLoad my app load first page instead of sixNave
K
0

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;
    }
}
Kernan answered 2/11, 2013 at 23:41 Comment(3)
@RomanSimenok, what do you mean by your comment? Are you getting an error message? If, so you need to post the code you tried.Kernan
yes, error, but viewDidAppear is wrong way, for example even if i put there [self.tabBarController setSelectedIndex:6]; it will always send me to the 6 page, so only viewWillLoad works here, i try to make come "if" there, but i get only errors.Nave
@RomanSimenok, it shouldn't always send you to 6, only the first time the view appears. I've tested my code and it works fine for me. As I said above, you should edit your question to show the code you're using now.Kernan
N
0

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

Nave answered 6/11, 2013 at 14:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.