Ios 自定义UITableView部分不增加高度
我正在尝试创建一个自定义的TableView部分。这高于正常的节标题 问题是当我将高度从18增加到30时。没有发生任何事情,它不会变得更大。我做错了什么 我有以下代码:Ios 自定义UITableView部分不增加高度,ios,iphone,objective-c,uitableview,Ios,Iphone,Objective C,Uitableview,我正在尝试创建一个自定义的TableView部分。这高于正常的节标题 问题是当我将高度从18增加到30时。没有发生任何事情,它不会变得更大。我做错了什么 我有以下代码: -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView
-(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:12]];
NSString *string =[[sectionsArray objectAtIndex:section] objectForKey:@"league"];
/* Section header is in 0th index... */
[label setText:string];
[view addSubview:label];
[view setBackgroundColor:[UIColor colorWithRed:166/255.0 green:177/255.0 blue:186/255.0 alpha:1.0]]; //your background color...
return view;
}
实施此方法:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 18.0; // whatever height you want
}
如果您使用的是iOS 7,还可以使用Implement以下方法:
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection: (NSInteger)section NS_AVAILABLE_IOS(7_0);
请参阅UITableViewDelegate
tableView:HeightforHeader部分: