0
votes

I have 2 viewcontrollers in a TabBarController, in 2nd ViewController I have a button which on click should take me to ThanksViewController with out Tabs anymore!!

Please check my code below:

//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];

In my TwoViewController (tab 2) I've a Button 'OK' which on click should take me to ThanksViewController, for that I've written the following code:

//TwoViewController.m

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

My problem is I want to exit from TabBarController and move on to the ThanksViewController(without TabBarController at the bottom) but in this case I'm getting the ThanksViewController in the TabBarController itself in place of the TwoViewController.

Can someone please suggest me in this case, thanks in advance.

1
That was my post but couldn't get a proper response so I thought of making it more clear in this post - maddy

1 Answers

0
votes

After push ThanksViewController do you want to be possible to go back and present TabBarController again? If so, use modal, like this:

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

[navThanks setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];

[self presentModalViewController:navThanks animated:YES];
[self.view setHidden:YES];