【问题标题】:Parse data image shows in iOS simulator but not in device解析数据图像显示在 iOS 模拟器中但不在设备中
【发布时间】:2013-07-12 11:34:57
【问题描述】:

我正在使用集合视图控制器来显示缩略图。单击缩略图,segue 会以模态方式打开完整图像。它在模拟器上运行良好,但在我的 iphone 或 ipad 上却不行。完整的图像是空白的。 “评论”显示在所有设备中。

这是转场:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showBandPhoto"]) {
        NSArray *indexPaths = [self.collectionView indexPathsForSelectedItems];
        BDBPhotoViewController *destViewController = segue.destinationViewController;
        NSIndexPath *indexPath = [indexPaths objectAtIndex:0];

        PFObject *tempObject = [imageObjectsArray objectAtIndex:indexPath.row];
        PFFile *imageFile = [tempObject objectForKey:@"image"];
        NSData *imageData = [imageFile getData];
        UIImage *image = [UIImage imageWithData:imageData];
        destViewController.bandImageName = image;
        NSLog(@"image is %@", image);
        NSString *commentGet = [tempObject objectForKey:@"comment"];
        destViewController.comment = commentGet;

这是照片控制器 viewDidLoad 的代码:

self.photoImageView.image = bandImageName;
    self.commentLabel.text = comment;

【问题讨论】:

  • 在检索数据之前segue是否完成?仍然不知道为什么模拟器会工作。

标签: ios imageview reload parse-platform


【解决方案1】:

不要使用UIImageView,而是尝试使用PFImageView。这个子类使直接从 Parse 加载图像数据变得更加容易。

【讨论】:

  • 试过 PFImageView,但没有变化。感谢您的建议。
【解决方案2】:

我不确定为什么会这样,但我将检索从 Parse 移到 viewDidLoad 并在那里创建了图像数组。当 segue 被调用时,它从数组中获取图像,而不必查询 Parse。

【讨论】:

    【解决方案3】:

    对我来说,问题是我在图像命名中添加了扩展名。模拟器可以读取图像但不能读取设备。当我删除扩展时它起作用了。

    此外,如本文所述: images in iphone app appear in simulator but not when compiled to device

    Mac 文件系统不区分大小写,iOS 文件系统区分大小写。由于图像命名,您的问题可能是正义的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-24
      • 2011-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      相关资源
      最近更新 更多