0

我在 TabBarController 中有 2 个视图控制器,在第二个 ViewController 中我有一个按钮,单击该按钮应该带我到ThanksViewController 没有标签了!!

请在下面检查我的代码:

//AppDelegate.m

UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:_viewController];
    self.window.rootViewController = nav;

//ViewController.m

tab=[[UITabBarController alloc]init];
    tab.delegate=self;

    oneViewController=[[OneViewController alloc]init];

    UINavigationController *oneNav=[[UINavigationController alloc]initWithRootViewController:oneViewController];
    oneNav.title=@"One";

    twoViewController=[[TwoViewController alloc]init];

    UINavigationController *twoNav=[[UINavigationController alloc]initWithRootViewController:twoViewController];
    twoNav.title=@"Two";

    views=[[NSMutableArray alloc]initWithObjects:oneNav, twoNav, nil];

    tab.viewControllers=views;
    [tab.view setFrame:CGRectMake(0, 0, 1024, 748)];

    [self.view addSubview:tab.view];

在我的 TwoViewController(选项卡 2)中,我有一个“确定”按钮,单击它应该带我到 ThanksViewController,为此我编写了以下代码:

//TwoViewController.m

-(void)OK
{
    ThanksViewController *thanksViewController=[[ThanksViewController alloc]init];
    [self.navigationController pushViewController:thanksViewController animated:YES];
}

我的问题是我想从 TabBarController 退出并转到ThanksViewController(底部没有 TabBarController),但在这种情况下,我在 TabBarController 本身中使用了 ThanksViewController 来代替 TwoViewController。

有人可以在这种情况下建议我吗,在此先感谢。

4

1 回答 1

0

推送ThanksViewController 后,您是否希望可以返回并再次呈现TabBarController?如果是这样,请使用模态,如下所示:

ThanksViewController *view = [[ThanksViewController alloc] init];
UINavigationController *navThanks = [[UINavigationController alloc] initWithRootViewController:view];

[navThanks setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];

[self presentModalViewController:navThanks animated:YES];
[self.view setHidden:YES];
于 2013-08-20T15:34:49.580 回答