Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义UITableView部分不增加高度_Ios_Iphone_Objective C_Uitableview - Fatal编程技术网

Ios 自定义UITableView部分不增加高度

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

我正在尝试创建一个自定义的TableView部分。这高于正常的节标题

问题是当我将高度从18增加到30时。没有发生任何事情,它不会变得更大。我做错了什么

我有以下代码:

-(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部分: