viewWithTag returns nil when initializing a UICollectionViewCell

落花浮王杯 提交于 2019-12-04 05:17:28

Remove the registerClass line. You are doing it on storyboard, so you don't need it.

try it

UILabel *nameLabel = (UILabel *)[cell.contentView viewWithTag:100];

Update:

You can look the cell's hierarchy and all its subview's tag :[self showAllSubView:cell] ;, can you find your label with tag 10 ?

- (void)showAllSubView:(UIView *)view
{
    for (UIView * subView in [view subviews]) {
        NSLog(@"%@, tag:%d", subView, subView.tag) ;
        [self showAllSubView:subView] ;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!