简体   繁体   English

重置标签栏控制器的视图控制器

[英]Resetting Tab bar controller's view controllers

In my Application I have creted view controllers for Tab Bar using XIB. 在我的应用程序中,我使用XIB创建了Tab栏的视图控制器。 I mean I added view controllers in tab bar using XIB. 我的意思是我使用XIB在选项卡栏中添加了视图控制器。 See picture, 看图片

在此处输入图片说明

So my application is like this. 所以我的应用程序就是这样。 I have a log out functionality that will show login page. 我有一个注销功能,它将显示登录页面。 From Login page I have displayyed tab bar as 在登录页面中,我将标签栏显示为

    [self.view addSubview tabBarController.view];

When I log out I simply remove this tab bar and show login screen as 当我注销时,只需删除此标签栏,然后将登录屏幕显示为

    [self.tabBarController.view removeFromSuperView];

Then It will show login screen. 然后它将显示登录屏幕。 When I login again, The view controllers inside tab bar is not reset. 当我再次登录时,选项卡栏中的视图控制器未重置。 I mean If I have showed some data like names in table view, It will be there as it is when I logged in again (some time I login as different user and I get details for previous user.). 我的意思是,如果我在表视图中显示了一些数据,例如名称,那么它将再次出现时保持原样(有时我以其他用户身份登录,并获得了先前用户的详细信息。)。 I tried 我试过了

    self.tabBarController.viewControllers = nil;

to reset all view controllers, but it not works any more. 重置所有视图控制器,但不再起作用。 I think each time When I log in all view controllers should call ViewDidLoad: , currently it is calling viewWillAppear: . 我认为每次登录时,所有视图控制器都应调用ViewDidLoad:当前它正在调用viewWillAppear: ViewDidLoad: So please let me know how could I resolve this issue 所以请让我知道如何解决这个问题

I think since you are not using a fresh object once you sign out and sign in again, it is showing you with the last stage. 我认为,既然您在退出并再次登录后就没有使用新对象,那么它将向您显示最后一个阶段。 Try initializing your controller object after you have logged in may work for you. 登录后尝试初始化控制器对象可能对您有用。

Let me know if you find any problem further. 让我知道您是否还有任何问题。

Cheers Tarun 干杯塔伦

All it's troubles because you use Interface Builder. 麻烦全都因为您使用了Interface Builder。 Ok, try to explain. 好的,尝试解释一下。 In your class like MyViewController.m ypu need set property like this: 在像MyViewController.m这样的类中,ypu需要这样的set属性:

@interface MyViewController : UIViewController
{
    IBOutlet UITabBarController *mytabbar;
}

In IB (Interface Builder) you need set mytabbar property name for your UITabBarController. 在IB(界面生成器)中,您需要为UITabBarController设置mytabbar属性名称。 After that you can rectreate this variable, because you have pointer to this variable. 之后,您可以撤回该变量,因为您有指向该变量的指针。

暂无
暂无

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

相关问题 当视图控制器超过5个时,为什么设置选项卡栏控制器的selectedViewController> = 4会引发错误? - Why does setting tab bar controller's selectedViewController >= 4 throw error when there are more than 5 view controllers? 检查View Controllers的选项卡栏成员是我的View Controller吗? - Checking View Controllers' tab bar member is my view controller? 在视图控制器->标签栏控制器->导航控制器->视图控制器的层次结构内旋转视图控制器 - Rotating view controllers within a hierarchy of View Controller -> Tab Bar Controller -> Navigation Controller -> View Controller 标签栏控制器中的视图控制器在旋转时不会自动调整大小 - View controllers inside tab bar controller not auto-resizing on rotation 如何防止标签栏控制器中的视图控制器旋转? - How to prevent the view controllers in a tab bar controller from rotating? 标签栏控制器中的导航控制器 - Navigation Controllers in tab bar controller 在选项卡栏控制器 - >导航控制器 - >视图控制器的层次结构内旋转视图控制器 - Rotating view controllers within a hierarchy of Tab Bar Controller -> Navigation Controller -> View Controller 如何将选项卡栏控制器添加到拆分视图控制器应用程序的根视图中 - How to add tab bar controllers to the root view of the split view controller application 如何获取选项卡栏控制器中包含的所有视图控制器? iPhone开发人员 - How to get all the view controllers that is included within a tab bar controller? Iphone dev 在应用程序的所有视图控制器上显示选项卡栏 - Show tab bar on all view controllers of application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM