一种思路(不好的思路)
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
static int i;
if (indexPath.row == currentRow) {
i = i + 1;
return 130 + ((i+1)% 2) * 40;
}
else{
return 130;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailView = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
User *user = [userArray objectAtIndex:indexPath.row];
currentRow= [indexPath row];
[detailView sendName:[user name]];
NSLog(@"USERNAME:%@", [user name]);
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
//在网络应用中调用reloadData是一个不明智的选择。
[self.tableView reloadData];
}
另外一个方法是:
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
// [self.tableView reloadData];
[self.tableView beginUpdates];
if (currentRow == [indexPath row]) {
currentRow = -1;
}
else
{
currentRow = [indexPath row];
}
[self.tableView endUpdates];
不调用reloadData