1.错误提示:[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused
代码(分返回空的Cell):
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath
*)indexPath
{
UICollectionViewCell * cell =
nil;
SelectCell *cell = [collectionView
dequeueReusableCellWithReuseIdentifier:@"SelectContactsViewCell"
forIndexPath:indexPath];
EMGroup * group =
self.myDataSource[indexPath.row];
cell.lable.text = group.groupSubject;
cell.imageview.image =[UIImage
imageNamed:@"communityspace.png"];
//忘记赋值了
return cell;
}
2.[superView addSubView:childView]
当superView.frame = CGRectZero;childView!= CGRectZero 该死的childView一直显示着,误打误撞设置了下superView.clipsToBounds =YES;
本文解决UICollectionViewCell复用导致的空Cell问题及视图层级中superView.frame为CGRectZero时childView异常显示的问题。通过正确使用dequeueReusableCellWithReuseIdentifier及设置superView.clipsToBounds=YES来确保UI正常渲染。


被折叠的 条评论
为什么被折叠?



