I am trying to update the code in one of my applications to iOS7, and I navigate to it using the storyboard. I ran into a problem trying to get a table title to display more than one line of text (table table cells still work fine).
A TableView was created using Storyboard, but I am using a custom cell from an old program instead of creating a new custom cell in Storyboard.
My code that worked fine:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { switch (section) { case 0: return [NSString stringWithFormat:@"Fixture Counts per \nTable 2902.1 - %@ IBC\n\n Occupancy Recap", strCodeYear ]; //(rounded up) break; case 1: return [NSString stringWithFormat:@"Womens Fixtures"]; break; case 2: return [NSString stringWithFormat:@"Mens Fixtures"]; break; case 3: return [NSString stringWithFormat:@"General Fixtures"]; break; } // To avoid "control reaches end of non-void function" return 0; }
\ n was enough for the title to expand with text strings. I can say that \ n still returns, but only one line of text is visible.
I resized the title to make sure there is enough space, but still only one line of text:
// Set Custom Heights for Headers -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if(section == 0 ) return 200.0f; else return 60.0f; // put 22 in case of plain one.. }
I tried to find a way to use numberOfLines as a label, but to no avail. I looked at the UITableView Reference and didn’t see anything referring to the number of rows, but I tried anyway:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *label = [[UILabel alloc] init]; label.numberOfLines = 2; return 0;
Any help is appreciated.
source share