我想你誤會tableView:heightForRowAtIndexPath:
被多次調用(一次爲每個行的表格)。
如果你的行有不同的高度,那麼你需要確定你所在的行和應該具有的高度。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
CGFloat height;
if (0 == indexPath.row) {
// This is the first row
height = // what ever you want
} else if (1 == indexPath.row) {
// This is the second row
height = // what ever you want
}
return height;
}
如果您稍後決定行需要一個不同的高度,然後它仍然是這個方法需要計算用於每個行正確的高度。你可以強制這個被調用,而無需重新加載tableView像這樣
[tableView beginUpdates];
[tableView endUpdates];
你是指當選擇第一行嗎? – arnoapp 2012-08-06 12:32:18
編號當初始化自己... – 2012-08-06 12:34:18
你能指定什麼是你確切的要求。你可以找到一個替代解決方案,而不是在第二行時更改第一行高度。 – Anish 2012-08-06 12:35:26