简体   繁体   English

自定义UITableView部分不增加高度

[英]Custom UITableView Section not increasing height

I'm trying to make a custom TableView Section. 我正在尝试制作自定义的TableView部分。 That is higher than the normal section header. 这比正常的节头更高。

The problem is when i example increase the height from 18 to 30. Nothing happen it does not get any bigger. 问题是当我的例子将高度从18增加到30.没有任何事情发生它没有变得更大。 What am i doing wrong? 我究竟做错了什么?

i have this code: 我有这个代码:

-(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;
}

Implement this method : 实现此方法:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
   return 18.0; // whatever height you want
}

If you are using iOS 7, you can use implemeent the following method also : 如果您使用的是iOS 7,则还可以使用以下方法:

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection: (NSInteger)section NS_AVAILABLE_IOS(7_0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM