我有一个包含 2 个部分的 tableView,部分数组固定有 2 个元素。这些部分的标题显示良好,如下面的 Xcode 7 中的代码所示。我刚刚升级到 Xcode 8,部分标题不再显示,下面的代码不再被调用。
有任何想法吗?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)];
/* Create custom view to display section header... */
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 18)];
[label setFont:[UIFont boldSystemFontOfSize:16]];
NSString *date =[sections objectAtIndex:section];
/* Section header is in 0th index... */
[label setText:date];
[view addSubview:label];
[view setBackgroundColor:[DeviceHelper Orange]]; //[UIColor colorWithRed:166/255.0 green:177/255.0 blue:186/255.0 alpha:1.0]]; //your background color...
return view;
}