Ios 自动布局导致uitableviewcell使用重用单元格中的路径
我有自定义的Ios 自动布局导致uitableviewcell使用重用单元格中的路径,ios,uitableview,autolayout,uibezierpath,cashapelayer,Ios,Uitableview,Autolayout,Uibezierpath,Cashapelayer,我有自定义的UITableViewCells,每个单元格都有一个UIView,具有唯一的UIBezierPath。由于实现了自动布局,我看到重用的单元呈现了当前单元的路径和它们正在重用的单元的路径。例如,第7行位于其唯一路径的顶部-如果我向下滚动到第2行,第2行中的视图将在同一视图中显示其自己的路径和第7行。第6行和第1行也是如此。如果我从xib文件的视图中删除所有约束,问题就会消失。知道为什么会这样吗 - (UITableViewCell *)tableView:(UITableView *)
UITableViewCells
,每个单元格都有一个UIView
,具有唯一的UIBezierPath
。由于实现了自动布局,我看到重用的单元呈现了当前单元的路径和它们正在重用的单元的路径。例如,第7行位于其唯一路径的顶部-如果我向下滚动到第2行,第2行中的视图将在同一视图中显示其自己的路径和第7行。第6行和第1行也是如此。如果我从xib文件的视图中删除所有约束,问题就会消失。知道为什么会这样吗
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* identifier = @"audioTableCell";
OSAudioTableCell *cell = [self.audioTable dequeueReusableCellWithIdentifier:identifier];
if(cell == nil)
{
cell = [[OSAudioTableCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: identifier];
}
else
{
[cell.waveView.blueWave removeFromSuperlayer];
[cell.waveView.redWave removeFromSuperlayer];
cell.waveView.blueWave = nil;
cell.waveView.redWave = nil;
cell.waveView.path = nil;
cell.trackLabel.text = nil;
}
Recording * recording = [self.fetchCon objectAtIndexPath:indexPath];
NSData * pathData = recording.waveData;
cell.waveView.path = [NSKeyedUnarchiver unarchiveObjectWithData:pathData];
[cell setImageSize:cell.waveView.bounds.size];
cell.tag = indexPath.row;
UIView * cellBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cellBackgroundView.backgroundColor = [UIColor clearColor];
cell.multipleSelectionBackgroundView = cellBackgroundView;
cell.selectedBackgroundView = cellBackgroundView;
}
-(void) prepareForReuse
{
[super prepareForReuse];
[self.timer invalidate];
self.waveView.progress= 0;
}
prepareForReuse方法是在视图控制器中还是在OSAudioTableCell.m中?应该在单元格中,但从代码片段看,它似乎在视图控制器中。很抱歉,没有澄清-它在OSAudioTableCell.m中