简体   繁体   中英

Parse data image shows in iOS simulator but not in device

I'm using a collection view controller to show thumbnails. Click on the thumbnail and a segue opens to the full image modally. It works fine on the simulator, but not on my iphone or ipad. The full image is blank. The "comment" shows up in all devices.

Here's the segue:

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

Here's the code for the photo controller viewDidLoad:

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

Instead of using UIImageView , try using a PFImageView . This subclass makes it much easier for loading image data directly from Parse.

I'm not sure why this worked, but I moved the retrieval from Parse to viewDidLoad and created the image array there. When the segue is called it gets the image from the array, rather than having to query Parse.

For me the problem was that I added extension in image naming. The simulator could read the image but not the device. when I removed extension it worked.

Furthermore, as explained in this post: images in iphone app appear in simulator but not when compiled to device

Mac file system is case-insensitive and iOS file system is case sensitive. Your problem is maybe juste due to image naming.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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