`

UITableView——在程序运行中调整UITableViewCell高度

    博客分类:
  • ios
 
阅读更多

 

BOOL bCheck[20]; (也可以是NSArray,里面添加NSNumber成员,记录cell高度,这里简单用bool数组)

记录每个cell的高度,

然后在:

 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

 

    if (bCheck[indexPath.row]) {

 

        return 100;

    }else{

 

        return 50;

    }

}

 

最后处理选择操作:

 

 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    bCheck[indexPath.row] = YES;

    [tableView reloadData];

    bCheck[indexPath.row] = NO;

}

 

//知更某一行的数据

[tableView reloadRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

 

 

 

使用这行代码来设置tableView的初始位置:    

 

tableview setContentOffset:CGPointMake(0,480) animated:YES];

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics