6
我想更改所选单元格的大小。 但是,他们改变了触摸单元的位置。当您选择单元格时,UITableViewCell更改单元格的大小
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *currentCell = [aTableView cellForRowAtIndexPath:indexPath];
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:currentCell];
[UIView setAnimationDidStopSelector:@selector(endAnimation)];
float extendedSize = currentCell.frame.size.height;
currentCell.frame = CGRectMake(currentCell.frame.origin.x, currentCell.frame.origin.y, currentCell.frame.size.width, currentCell.frame.size.height + extendedSize);
UITableViewCell *afterCell;
for (int i=indexPath.row+1; i<=[aTableView numberOfRowsInSection:indexPath.section]; i++) {
afterCell = [aTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
afterCell.frame = CGRectMake(afterCell.frame.origin.x, (afterCell.frame.origin.y + extendedSize), afterCell.frame.size.width, afterCell.frame.size.height);
}
[UIView commitAnimations];
}
谢谢。
这次成功的。 动画正常工作。 谢谢。 – tochi 2010-07-04 21:54:05
不客气。 – 2010-07-05 20:22:55
if([indexPath isEqual:[tableView indexPathForSelectedRow]]) – andrei200287 2013-07-30 09:23:29