Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Images from Parse Not Loading On iOS 9

I got a PFQueryCollectionViewController populated by images, everything works fine on iOS 8.x.x and below, but when I run the application on iOS 9 using Xcode 7 Beta all the images are blank.

Here's the code I use to load images from Parse in the PFQueryCollectionViewController

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

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];

    UIImageView *imageView = (UIImageView*)[cell viewWithTag:1];

    if([object objectForKey:@"image"] != NULL) {

        [[object objectForKey:@"image"] getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {                

            UIImage *thumbnailImage = [UIImage imageWithData:imageData];
            UIImageView *thumbnailImageView = [[UIImageView alloc] initWithImage:thumbnailImage];

            imageView.image = thumbnailImageView.image;

        }];

        }

     return cell;

}

and

- (PFQuery *)queryForCollection {

    PFQuery *query = [PFQuery queryWithClassName:@"Class"];   

    ...

    return query;
}
like image 562
Hugo Avatar asked Jun 26 '15 17:06

Hugo


2 Answers

This is probably due to SSL requirements with iOS 9. Since Parse doesn't use HTTPS for files, they won't download correctly. Set the info.plist to include keys such as this, which turn off the SSL requirements...at your own risk, of course:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>files.parsetfss.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
        </dict>
    </dict>
like image 137
akaru Avatar answered Oct 10 '22 06:10

akaru


Find Enable bitcode in Build settings in respective target AND set it to NO

like image 24
Chamira Fernando Avatar answered Oct 10 '22 08:10

Chamira Fernando