开发者

Is it possible to refresh the TabbarController when a user selects a particular tab in iPhone?

开发者 https://www.devze.com 2023-01-11 21:53 出处:网络
I have a TabbarController with 3 tabs with each tab representing a navigation Controller. What I would like to do is when a user selects a particular tab the whole tabbar Controller should refresh.

I have a TabbarController with 3 tabs with each tab representing a navigation Controller. What I would like to do is when a user selects a particular tab the whole tabbar Controller should refresh.

To make it more clear...

When a user selects tab0 and navigates in that tab 2-3 times and then the user selects tab1. Now when the user again selects tab0 it retains the last viewed ViewController. Can I make to show the first viewController in that tabbar NavigationController.

Can anyone help me in resolving this problem...

Any code will be very helpful...

Tha开发者_StackOverflow中文版nx in advance...

Plz help me.....


Set yourself as the tab bar delegate and implement tabBar:didSelectItem: as per below.

You can then popToRootViewController on your relevant ViewController:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if (item.tag == kRelevanTabBarIndex) {
        [self.relevantNavController popToRootViewControllerAnimated:NO];
    }
}

Cheers, Rog

0

精彩评论

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