Jim Clermonts
Jim Clermonts

Reputation: 2660

Tab bar moves away from screen

My Tab bar should stay on screen when I click on button in Test2 View Controller.

I've set Test 3 View Controller's Bottom bar to inferred and tried Translucent tab bar. I've changed the segue from push to modal. I've tried this solution, but doesn't work for iOS7.

TestTabBarController.m this doesn't work either:

- (void)viewDidLoad
{
    Test3ViewController * viewController1 = [[Test3ViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController *homeNavi=[[UINavigationController alloc]initWithRootViewController:viewController1];
    self.viewControllers = [NSArray arrayWithObjects:homeNavi, nil];    
}

This also doesn't work:

- (IBAction)buttonpress:(id)sender {      
   UIStoryboard *storyboard = [UIStoryboard   storyboardWithName:@"Main" bundle:nil];       
   Test3ViewController * test3ViewController = (Test3ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"test3View"];     
   [self.navigationController pushViewController:test3ViewController animated:YES]; 
}

enter image description here

Upvotes: 1

Views: 56

Answers (3)

Jim Clermonts
Jim Clermonts

Reputation: 2660

The answer is: Add a Navigation controller between Test Tab Bar Controller and Test2 View Controller.

Upvotes: 0

CW0007007
CW0007007

Reputation: 5681

A modal view will cover the tab bar. If you want to load a view after you hit the 'Button' do the following:

- (IBAction) loadNewView:(id) sender {
    Test3ViewController * viewController1 = [[Test3ViewController alloc] initWithNibName:nil bundle:nil];
    [[self navigationController] pushViewController:viewController1 animated:YES];
}

Then link that up with your button...

Upvotes: 0

gran33
gran33

Reputation: 12991

First: Your link Test2 to Test3 in storyboard is Modal, change it to Push: enter image description here

And u'll see your navigation bar.

Second: Don't use the segue mechanism for your task. Use the pushViewController on UINavigationController

Upvotes: 1

Related Questions