【发布时间】:2015-03-18 04:43:58
【问题描述】:
我有一个简单的表格视图,我正在使用带有一个 UIImage 和一些标签的自定义单元格。
我想为图像大小设置动画,为此我在cellForRowAtIndexPath 方法中添加了以下内容:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"customCell";
NotificationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[NotificationTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if( [[[notification objectAtIndex:[indexPath section]] valueForKey:@"readed"] isEqualToString:@"readed"])
{
[UIView animateWithDuration:0.9
delay:0.3
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionRepeat
animations:(void (^)(void)) ^{
cell.imgIcon.transform=CGAffineTransformMakeScale(0.8, 0.8);
}
completion:^(BOOL finished){
cell.imgIcon.transform=CGAffineTransformIdentity;
}];
}
return cell;
}
当我启动应用程序时,它运行正常,只有“已读取”的单元格在带有 UIViewAnimationOptionRepeat 选项的 bucle 中进行动画处理。
当我滚动表格视图时,问题就开始了。一些“读取”的单元格停止动画,并且每个单元格的单元格动画时间循环不同。
有什么想法吗?
谢谢
已编辑:我认为问题出在可重复使用的单元格上。
【问题讨论】:
标签: ios objective-c uitableview animation tableviewcell