johnbakers
johnbakers

Reputation: 24771

UITableView first row is cut off

What would cause the first row of a table in a nav controller to be positioned so part of it is under the nav controller?

I cannot seem to get it to show the whole row top to bottom; It may seem minor, but it's clearly not correct and I find it unattractive.

TableViewController added to nav controller entirely in code:

     SettingsRootController*settings=[[SettingsRootController alloc] initWithStyle:UITableViewStylePlain];
    self.settingsView=[[[UINavigationController alloc] initWithRootViewController:settings]autorelease];
    [settings release];

SettingsRootController is a subclass of UITableViewController.

What would cause the first row of a table in a nav controller to be positioned so part of it is under the nav controller?

Upvotes: 0

Views: 1600

Answers (2)

johnbakers
johnbakers

Reputation: 24771

the only thing that seems to work is manually shifting the table view inside the nav controller down by 10 pixels, but only on iPhone, not on iPad, since there is no alignment problem on iPad and shifting by 10 pixels on iPad creates a gap. this is clearly some sort of nav controller bug, as there are other weird issues noted in other threads.

 CGPoint tableorigin=CGPointMake(0,ISIPAD?0:10);

Upvotes: 1

Neo
Neo

Reputation: 1236

It seems that it is a common problem with programmatically-added UINavigationController - see Adding a UINavigationController as a subview of UIView.

Basically, what you should probably do is to set the frame property of UINavigationController before you add it as a subview to anywhere. In the accepted answer to the above question there's also a suggestion to alter the UINavigationController's frame to:

nav.view.frame = CGRectMake(nav.view.frame.origin.x, nav.view.frame.origin.y - 20,
                      nav.view.frame.size.width, nav.view.frame.size.height);

Upvotes: 1

Related Questions