0
在cellForItemAtIndexPath錯誤圖像UICollectionView單元複用的ImageView將顯示哪些不屬於它
- (void)setupDeskWithLessonRole:(LessonRole *)role{
[self initializeCell];
if (role) {
_stuPortrait.hidden = NO;
_genderSign.hidden = NO;
if (role.userInfo.gender.integerValue == UserGenderTypeMale) {
[_stuPortrait sd_setImageWithURL:[NSURL URLWithString:role.userInfo.portraitUrl] placeholderImage:[UIImage imageNamed:@"Student_por_boy"]];
} else {
[_stuPortrait sd_setImageWithURL:[NSURL URLWithString:role.userInfo.portraitUrl] placeholderImage:[UIImage imageNamed:@"Student_por_girl"]];
}
_genderSign.image = [role.userInfo.gender intValue] == 0? [UIImage imageNamed:@"Lesson_boySign"] : [UIImage imageNamed:@"Lesson_girlSign"];
_name.text = role.userInfo.nickName;
[_stuPortrait setBoardWidth:2 hexColor:[role.userInfo.gender intValue] == 0? @"4dc2ff":@"ff6683 "];
if (role.isSpeaking) {
[self startAnimation];
} else {
[self stopAnimation];
}
if (role.isRaisingHand){
_raiseHandIcon.hidden = NO;
} else {
_raiseHandIcon.hidden = YES;
}
}
}
和
- (void)prepareForReuse{
[super prepareForReuse];
[self initializeCell];
}
時reloadData在一些細胞中的ImageView,它的作用是空的將顯示一個圖像 enter image description here
一個圖片顯示,當第二個角色進來時,我重新加載數據,第二個角色的圖像將顯示我n其他單元格的圖像視圖