Seçili hücrenin takip etmek için bir özellik ekleyin
@property (nonatomic) int currentSelection;
(Örneğin) bir sentinel değere ayarlayın viewDidLoad, emin olmak için UITableView'normal' pozisyonunda başlar
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//sentinel
self.currentSelection = -1;
}
Gelen heightForRowAtIndexPathsen yüksekliğini ayarlayabilirsiniz seçilen hücre için istediğiniz
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
int rowHeight;
if ([indexPath row] == self.currentSelection) {
rowHeight = self.newCellHeight;
} else rowHeight = 57.0f;
return rowHeight;
}
In didSelectRowAtIndexPathgerekirse size, geçerli seçimi kaydetmek ve dinamik bir yüksekliğe kaydetmek
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// do things with your cell here
// set selection
self.currentSelection = indexPath.row;
// save height for full text label
self.newCellHeight = cell.titleLbl.frame.size.height + cell.descriptionLbl.frame.size.height + 10;
// animate
[tableView beginUpdates];
[tableView endUpdates];
}
}
Gelen didDeselectRowAtIndexPathsentinel değerine geri seçim endeksi ayarlanır ve normal forma hücre animasyon
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
// do things with your cell here
// sentinel
self.currentSelection = -1;
// animate
[tableView beginUpdates];
[tableView endUpdates];
}
}