我在TabBarController中有2个viewcontrollers,在第2个ViewController中我有一个按钮,点击它应该带我到带有Tabs的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。
有人可以在这种情况下建议我,提前谢谢。
答案 0 :(得分: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];