Switching to a TabBar tab view programmatically?
original source : https://stackoverflow.com/questions/5413538/switching-to-a-tabbar-tab-view-programmatically
두가지 방법이 있는 것으로 추측된다.
selectedIndex에 새로운 index 값을 할당
self.tabBarController.selectedIndex = 1;
selectedViewController에 view controller를 할당한다.
My opinion is that
selectedIndex or using
objectAtIndex is not necessarily the best way to switch the tab. If you reorder your tabs, a hard coded index selection might mess with your former app behavior.
If you have the object reference of the view controller you want to switch to, you can do:
tabBarController.selectedViewController = myViewController
Of course you must make sure, that
myViewController really is in the list of
tabBarController.viewControllers. <- 주의사항