开发者

UIViewController in a UITabBarViewController reset when app logs out

I have a UITabBarController with three tabs, each is a UIViewController with a UITableView. I have a logout button and I want to clear out the UITableView in all of these UIViewController, so from one of the UIViewController I did:

NSArray * viewControllers = ((UITabBarController *)self.parentViewController).viewControllers;
AllGroupsViewController * agvc = [viewControllers objectAtIndex:1];
[agvc.groups removeAllObjects];
[agvc.table reloadData];
SearchViewController * svc = [viewControllers objectAtIndex:2];
[svc.results removeAllObjects];
[svc.table reloadData];

However, it seems that the NSArray of viewControllers is empty. Is there another way to reset everything again when you logou开发者_StackOverflowt?

The problem with my current app is that when I have a user who is logged in and uses the app. The he logs out and a new user logs in, that new user can still see the prior user history in the UITableView.. this is why I want to clear this out when a user logs out, across the three UIViewController in the UITabBarController


Would you check the value of self.parentViewController? I am not sure if it returns the tab bar controller.

Instead of self.parentViewController.viewControllers, do

self.tabBarController.viewControllers


Define that array in AppDelegate and during Application Start create TabController with Table View through Code.

Now with your logout button set the datalist or source of tableview to nil;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜