UICollection视图在设备上显示与在模拟器上不同的结果

时间:2013-05-03 19:41:45

标签: ios objective-c ipad uicollectionview

我正在试图找出以下代码段中可能发生的情况。我有一个集合视图,我将缩略图显示为已保存的图像。我还在最后插入了一个“新图像”图标,以便用户可以添加其他图像。

在iPad模拟器上看起来不错,但是当我在设备上运行时,我看不到“新图像”图标。我可以触摸它以打开摄像机视图控制器进行捕获/选择但图像不显示。有任何想法吗?这是代码......

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

static NSString *cellIdentifier = @"cvCell";

CVCell *cell = (CVCell *)[[self sectionImagesCollectionView] dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
if ([indexPath row] < [sectionImages count]){
    // Have an image so assign the photograph
    RFHSectionImages *sectionImage = [sectionImages objectAtIndex:[indexPath row]];
    UIImage *image = [UIImage imageWithData:[sectionImage photograph]];
    [[cell imageView] setImage:image];
} else {
    // Use the standard image
    UIImage *newPhoto = [UIImage imageNamed:@"New Image.png"];
    [[cell imageView] setImage:newPhoto];
}

return cell;

}

2 个答案:

答案 0 :(得分:3)

以下是许多开发人员浪费时间的小细节:

区分大小写

真的,这一切归结为:

  • iPhone 模拟器:案例 - 不敏感
  • iOS 设备:案例 - 敏感

因此,您的代码中可能包含“New Image.png”,但实际图像名称为“new image.png”。它甚至可能是'nEw iMaGe.png'。

这可以在模拟器上正常工作,但设备上的 - 设备根本无法找到图像。

从图像到plists,这件事发生在我身上。

检查您的案例!

答案 1 :(得分:0)

我遇到了类似的问题,但罪魁祸首是网络延迟 - 必须手动调用self.collectionView.reloadData()才能显示出来。在本地,数据显然加载得足够快,这不是问题。

相关问题