Reputation: 9320
I created a customized section header with the following code, but the red label did not show.
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[[UIView alloc] init] autorelease];
UILabel * label1 = [[UILabel alloc] init];
label1.textColor = [UIColor redColor];
[headerView addSubview:label1];
return headerView;
}
Upvotes: 1
Views: 560
Reputation: 30846
The designated initializer for UILabel
is -initWithFrame:
and not -init
. Your label isn't appearing because you have not specified a frame for the view.
Additionally, I noticed that you haven't initialized headerView
with a frame either, but that appears to be working because the UITableView
is probably setting a new frame at some point. You should get in the habit of using the designated initializer.
Upvotes: 1