图像视图没有显示,但选择正在工作

时间:2013-11-07 22:38:14

标签: ios objective-c uicollectionview

我有一个集合视图,但图像没有显示,有趣的部分是方法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;

1 个答案:

答案 0 :(得分:1)

听起来你需要进行更深入的调试。

更改此单行:

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" );
 }

看看会发生什么。