简体   繁体   中英

How to change tab bar items after login in storyboard

I am new in iOS, working on Storyboard and have added Tabbar Controller with navigation controller in it. I want to change the tab bar items after successfully login.

Tab bar items(Before login)-> my contact, search, register, login.

Tab bar items(After login) -> my contact, search, My profile, Logout

Any help would be appreciated.

The same as without storyboard. Use UITabBarController's methods:

@property(nonatomic,copy) NSArray *viewControllers;
and
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated;

Sets the root view controllers of the tab bar controller.

When you assign a new set of view controllers at runtime, the tab bar controller removes all of the old view controllers before installing the new ones. When changing the view controllers, the tab bar controller remembers the view controller object that was previously selected and attempts to reselect it. If the selected view controller is no longer present, it attempts to select the view controller at the same index in the array as the previous selection. If that index is invalid, it selects the view controller at index 0.

To get UITabBarController you can use outlet mechanism or just get it from ViewController with self.tabBarController .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM