0
votes

I have a tab bar application and when I display a modal view controller, the content screen is offset by about 20 pixels to the top and left. It looks like this: included image

I'm presenting this view from the child view controller (detail view) of navigation controller (main view) of the tabview.

When I show the view, I'm hiding the tab bar and navigation bar but status bar is kept visible. Adjusting the view to be centered (through Interface Builder's Simulated Interface Elements->View Mode : Center) and changing the view's frame after a call to 'viewDidLoad' in the controller doesn't seem to shift it.

- (void)viewDidLoad {
// this still doesn't cause it to shift
self.view.frame = CGRectMake(0, 20, 320, 460);
}

What's the way to adjust this so that the content area is shown correctly?

I launch the child view like this:

[detailController presentModalViewController:tvc animated:NO];          

The app's view controller hierarchy:

Tab view with two child navigation controllers are created in the app delegate and the nav controllers added to the TabBar's view controllers:

tabBarController = [[UITabBarController alloc] init];   
tabBarController.viewControllers = [NSArray arrayWithObjects:tab1ViewController,    
                                    tab2ViewController, nil];

[window addSubview:tabBarController.view];

Each view controllers of the tab is created as a NavigationController with 1 view controller:

// MainViewController inherits from UIViewController
[MainViewController *viewController = [[MainViewController alloc] initWithNib..];

tab1ViewController.viewControllers = [NSArray arrayWithObject:viewController];

A detail view controller is launched with 'pushViewController' as a result of some action on tab1ViewController :

DetailController *detailController = [[DetailController alloc] 
                                                 initWithNibName:@"DetailView" 
                                                 bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:detailController animated:YES];

[detailController release];

It's from the detailController that I'm trying to launch the problem controller.

1

1 Answers

0
votes

Some things to check right off: is "viewDidLoad" actually getting called? If so, what is self.view.frame set to after the assignment? Put an NSLog at the end that prints out the x, y, width, height, and see what's there.

Also, since the trouble vc is modal, it will occupy the entire screen. "On iPhone and iPod touch devices, the view of modalViewController is always presented full screen."

HTH, Mike