ios - UITabBarController selectedIndex lagging by one click -


i have been using tabbarcontroller selectedindex determine whether navigation bar should displayed. working fine of today, line of code:

self.tabbarcontroller.selectedindex 

is giving last selected index rather selected index. running line of code in viewwillappear make sure particular view has index 1 in tabbarcontroller not show navigation bar on first view.

but it's reporting 1 click behind. example, when click on 2nd index , 1st index, last click shows having selected view controller @ index 2 though have clicked on view controller index 1. also, selectedindex listed correctly first time click on view controller never correct after first time viewed via tabbarcontroller.

i've looked on tabbarcontroller class reference, seems selectedindex property should straightforward. missing?

the problem have viewwillappear called before index has changed. first, tabbarcontroller shouldselectviewcontroller -> viewwillappear -> tabbarcontroller didselectviewcontroller -> viewdidappear. have similar setup reuse viewcontrollers across different tabbar indices. did not want check selectedindex in viewdidappear though fix problem. did fix problem go tag. both viewcontrollers have different uinavigationcontroller , set tag of 1 navbar 1. every time need know controller active check tag.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -