【发布时间】:2015-11-06 16:04:31
【问题描述】:
我正在实施TableViewController。除了UITableViewCellStyle 和NavigationControllerTitle 的小问题(我想我可以自己解决),我一直在为如何实现一些动画而烦恼。请注意,我搜索了很多主题(这也是一个:Can you do custom animations for UITableView Cell Inserts?)并尽可能多地在 Google 上搜索,但我不知道如何称呼我必须做的事情。所以我把它画得很清楚。
左侧有几个带有随机彩色小矩形的单元格。当我单击单元格时,此矩形会扩展为全宽,而不覆盖 CellText。
第二个动画同时发生,它插入某种数组,带有图像,扩展至底部并向下滑动其下方的单元格。
我真的很想写这个,但我所能做的就是将整个视图向右滑动,无处可去。
这是我认为我应该处理的 .m 文件。如果我要粘贴您的任何其他部分,请告诉我。
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
int selectedRow = indexPath.row;
NSLog(@"touch on row %d", selectedRow);
[self animate];
}
- (void)animate
{
[[self.tableView visibleCells] enumerateObjectsUsingBlock:^(UITableViewCell *cell, NSUInteger idx, BOOL *stop) {
[cell setFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
[UIView animateWithDuration:0.2 animations:^{
[cell setFrame:CGRectMake(320, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
}];
}];
}
感谢您的耐心等待,请理解我真的很想了解如何做到这一点。
【问题讨论】:
标签: ios uitableview animation