繁体   English   中英

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

[英]UICollection View shows different results on Device than on Simulator

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

在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;

}

这是一个很小的细节,许多开发人员浪费了几个小时:

区分大小写

真的,这一切归结为:

  • iPhone 模拟器 :Case- Insensitive
  • iOS 设备 :区分大小写

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

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

这种情况发生在我身上,从图像到plists。

检查你的案例!

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM