开发者

How do I reset a tabcontoller with a drill down table view

开发者 https://www.devze.com 2022-12-23 17:16 出处:网络
I have a tabbar with one of the tabs containing a drilldown table. I am having problems once the user has finished using the dr开发者_如何学运维illdown table.

I have a tabbar with one of the tabs containing a drilldown table.

I am having problems once the user has finished using the dr开发者_如何学运维illdown table.

If they change to another tab, then change back to the original tab, the original tab is still where I left it (at the bottom of the drill down showing the detail view).

What I want is on moving to an alternative tab the old tab resets.

I have tried adding all sorts of stuff to -(void)viewDidDisappear and -(void)viewDidUnload with no success.

What do I need to do?

Cheers


As I understood your question, you want the first view on every tab, whenever you move through tabs. You don't want the old view to be displayed there which you had left. Here is the code just use that in your appdelegate file:

(void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController{
    NSArray *vc= tabBarController1.viewControllers;
    for (int i = 0; i < [vc count]; i++) {
        UINavigationController *nc = [vc objectAtIndex:i];
        if (nc == tabBarController1.selectedViewController) {
            continue;
        }
        [nc popToRootViewControllerAnimated:NO];
    }   
}
0

精彩评论

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