您的位置:首页 > 产品设计 > UI/UE

iPhone开发笔记 (4) 如何改变UITableViewCell的行高

2012-02-26 16:05 501 查看
    在使用UITableView的时候,UITableViewCell的高度可能要改变。改变行高有两种情况,第一种是改变所有的行高。第二种是改变特定行的行高。

    第一种,改变所有行的行高。就是类似下面的效果。



这里要使用UITableViewDelegate的方法:

//设置rowHeight
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 91.5;
}
第二种,如果要指定改变某个行的行高。就类似下面的效果。



只要对上面的方法做一下修改如下:

//设置rowHeight
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 0) {
return 220;
}
else
{
return 40;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iphone