简体   繁体   English

登录情节提要后如何更改选项卡栏项目

[英]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. 我是iOS的新手,正在Storyboard上工作,并在其中添加了带有导航控制器的Tabbar Controller。 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: 使用UITabBarController的方法:

@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. 如果该索引无效,则选择索引0处的视图控制器。

To get UITabBarController you can use outlet mechanism or just get it from ViewController with self.tabBarController . 要获取UITabBarController,您可以使用插座机制,也可以仅通过ViewController的self.tabBarController获取它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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