【发布时间】:2019-03-18 05:00:42
【问题描述】:
我正在尝试将动画放在 UITableViewCell 中。动画是onClick table view cell将tableCell的frame变成tableview frame。
我有以下代码:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell*cell = [tableView cellForRowAtIndexPath:indexPath];
if(cell.frame.size.height == tableView.bounds.size.height){
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}else{
cell.frame = tableView.bounds;
[[cell superview] bringSubviewToFront:cell];
}
[UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
}];
}
它工作正常,但在更改单元格的框架后,我也可以点击另一个我不想要的单元格。我怎样才能做到这一点?
【问题讨论】:
-
你的问题不清楚,你的意思是改变单元格的框架后我也可以点击另一个单元格?
-
@vivekDas 请检查第二张图片,它是我更新的单元格。我禁用了表格视图滚动。如果我再次点击(假设在底部),则单元格(不是该单元格背面的这个单元格)被点击。清楚了吗?
-
我用过 [[cell superview] bringSubviewToFront:cell];成为选定单元格覆盖的方法
-
那么在过度单元格之后你想要什么?以及如何解除覆盖?
-
@vivekDas 我想如果我再次点击打开的单元格,它应该会刷新并且它正在工作,但其他单元格也处于活动状态,这是我不想要的。我只想吸引当前单元格
标签: ios objective-c uitableview animation