Scrolling UITableView below the navigation bar

I have a table view setup that currently, when it flickers, has its sections merging right under the status bar instead of flushing the navbar. I'm not sure if this is the correct behavior, but in many applications, the section header lights up properly below the navigation bar when it slides into view.

What's the correct way to fix this and not shrink the tableView arbitrarily?

* EDIT *

Related to the thread I created in Broken Cell with odd strikethrough? ... This problem plus the "cell break" problem occurs when I set my navbar to transparent black. When it is black, opaque or normal, there is no such problem. I'm not sure if this is the result of something else in my code or a problem with the SDK.

+1


source to share


4 answers


It looks like you either do not have boundaries set properly in IB, or your springs and struts are wrong. Is this a top-level UIViewController or a subview? Are you using UINavigationController? If you test the interface in IB, will it look ok?



+3


source


I had a similar problem and it gets fixed automatically by installing this



self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

      

+1


source


As I pointed out in another post, I suspect that the view hierarchy under the UINavigationController is broken.

The layoutSubviews in the content view (which contains the navigation bar and your UITableView) of the UINavigationController must size the UITableView so that it does not overlap the navigation bar. In your case, I am assuming that either the UITableView will resize afterwards, or the layoutSubviews for some reason is unaware of the UITableView and the UITableView passes under the navbar causing the alignment issue you are seeing.

0


source


I had the same problem on iOS 5.1 using the following code:

Create a navigation controller and add a table view

UINavigationController *navigationController = [[UINavigationController alloc] init];
[navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[navigationController.navigationBar setTranslucent:TRUE];
[navigationController setNavigationBarHidden:NO animated:NO];
[self presentModalViewController:navigationController animated:YES];

MyTableViewController *aTableViewController = [[[MyTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
aTableViewController.navigationItem.rightBarButtonItem = buttonItem;
[navigationController pushViewController:aboutTableViewController animated:YES];

      

Add table header view to table

ATableHeaderView aTableHeaderView = [[[ATableHeaderView alloc] initWithFrame:aboutTableView.frame] autorelease]; 
[aTableHeaderView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
[aTableHeaderView sizeToFit];
[aTableView setTableHeaderView:aTableHeaderView];

      

Inside the table header view, I added some shortcuts

UILabel *aLabel = [[[UILabel alloc] initWithFrame:CGRectMake(x,y, width, height)] autorelease];
[aLabel setText:aString];
[aLabel setAutoresizesSubviews:YES];
[aLabel setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];

      

I ended up with the content of the table header below the navigation bar. Changing the nav bar to solid black, she locked it in. But I didn't want that. After some trial and error, I removed the line:

[aLabel setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];

      

From setting UILabel in title and issue fixed. I have a semi-transparent title and the table contents are correctly positioned.

0


source







All Articles