我有一个 Collection View ,但没有显示图像,有趣的是 didSelectItemAtIndexPath 方法正在运行……可能是哪里出了问题?这是我的 cellForItemAtIndexPath 代码
cell *cell = [self.collectionPhotos dequeueReusableCellWithReuseIdentifier:@"CVCell" forIndexPath:indexPath];
NSString *nombre =[self.arrayPhotos objectAtIndex:indexPath.row];
//[cell.imageView setImage:[UIImage imageNamed:nombre]];
cell.imageView.image = [UIImage imageNamed:nombre];
return cell;
最佳答案
听起来您需要进行更深入的调试。
改变这一行:
cell.imageView.image = [UIImage imageNamed:nombre];
到:
if(cell)
{
UIImage * imageForCell = [UIImage imageNamed: nombre];
if(imageForCell)
{
if(cell.imageView)
cell.imageView.image = imageForCell;
else
NSLog( @"surprise, imageView is null" );
} else {
NSLog( @"can't find image named %@", nombre );
}
} else {
NSLog( @"cell is null" );
}
看看会发生什么。
关于ios - ImageView 未显示,但选择确实有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19848159/