【问题标题】:how to pop from one uitabbarcontroller to another如何从一个 uitabbar 控制器弹出到另一个
【发布时间】:2014-02-06 12:18:29
【问题描述】:
-(void)backButtonclicked
{
    ViewController *rvc = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
    [self.navigationController popToViewController:rvc animated:YES];

}

上面提到的是我在 tabcontroller 1 的 vc4 上做的事情

这是我的场景:

Tabcontroller1 vc1 - vc2 - vc3 - vc4

Tabcontroller2 vc1 - vc4(of tabcontroller 1)

现在当我从 vc4 弹出时,我想进入 vc1(tabcontroller 2) 并且在推送时我想去 tabcontroller 2 的 vc1 到 tabcontroller 1 的 vc4

请帮帮我。

【问题讨论】:

    标签: ios uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    您不应使用UINavigationController 更改UITabBarController 中的标签。

    如果您想更改选项卡,您应该获取UITabBarController 的实例并使用:

    tabBarController.selectedIndex = desiredIndex;
    

    这里有一个来自我项目的示例代码(我用一些动画来做):

    - (IBAction)mapButtonTapped:(UIBarButtonItem *)sender {
        UIView *startView = self.tabBarController.selectedViewController.view;
        UIView *endView = ((UIViewController *)[self.tabBarController.viewControllers objectAtIndex:ELMapViewControllerIndex]).view;
        [UIView transitionFromView:startView toView:endView duration:ELAnimationDuration
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        completion:^(BOOL finished) {
                            if (finished)
                                self.tabBarController.selectedIndex = ELMapViewControllerIndex;
                        }];
        ELMainMapViewController *carparkVC = [self.tabBarController.viewControllers objectAtIndex:ELMapViewControllerIndex];
        MKCoordinateRegion region = [self.delegate locationCoordinateForTappedMapButton];
        [carparkVC moveToRegion:region];
    }
    

    【讨论】:

    • 我用的是你上面提到的那个,是的,它可以工作,但仍然有一些问题。
    猜你喜欢
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 2017-03-23
    • 2014-07-23
    相关资源
    最近更新 更多