Reputation: 5197
I am trying to make only the first and second sections have section titles and make them not float. I added this to cell for row at index path:
cell.backgroundView = [[UIView alloc] initWithFrame:cell.bounds];
and made the tablestyle grouped to prevent the titles from floating. I also made the section footer and header height
for other sections (one's where I don't want the titles) CGFLOAT_MIN
and am returning a view of nil for each. How can I get rid of the annoying line below?
Upvotes: 0
Views: 132
Reputation: 40502
Rather than trying to use a grouped table view in an unintended why, it's much easier to use a regular table view and disable section header floating. You can do so in one of two ways:
CGFloat height = 40.f;
CGRect rect = CGRectMake(0, 0, CGRectGetWidth(self.tableView.bounds), height)];
UIView *dummyView = [[UIView alloc] initWithFrame:rect];
self.tableView.tableHeaderView = dummyView;
self.tableView.contentInset = UIEdgeInsetsMake(-dummyViewHeight, 0, 0, 0);
Section headers will now scroll just like any regular cell.
Alternately, UITableView
has two private methods that allow header floating to be enabled/disabled:
- (BOOL) allowsHeaderViewsToFloat;
- (BOOL) allowsFooterViewsToFloat;
If you are not concerned with using private APIs, just create a UITableView
subclass and return NO
for both of these methods.
Upvotes: 2