Reputation: 883
So, it's a fairly simple question.
I have a screen which has a button. Every time a user taps the button we let the user to pick a panoramic photo from his Photos, and add a UIImageView that displays the panoramic photo. Each UIImageView has a frame ~375x150 points(to show panoramic photo completely on iPhone 6).
The problem is that when we add second UIImageView we receive an error in NSLog: "Connection to assetsd was interrupted or assetsd died". Plus, we get slight UI 'freezes'. But UIImageView displays the second photo and we're absolutely okay.
And when we add third UIImageView the app simply crashes and Xcode displays "Lost connection to "Admin's iPhone 6"."
Considering panoramic photo resolutions (~13600x~3000) it's completely understandable why the app crashes and has UI freezes. The question is: is there anyway (except simply compressing the photo and showing the resized version on the screen) to show a lot of panoramic photos without lags? Looking at the Photos app, it displays panoramic photos without any bugs and doesn't have any UI freezes.
Upvotes: 2
Views: 722
Reputation: 13854
Your question is desceptively simple. You are right, the size of your images means that your app is grappling with memory issues. You're passing a huge image to a UIImageView
and hoping it will take care of everything for you. It won't, not with that much data.
The way the built-in Photos app gets around this is by using a technique called tiling, combined with resizing. It works something like this:
Google around, you might be able to find a library that takes care of that for you, and I think there even might have been an example from Apple (see this question). Otherwise, it's an interesting learning experience to write it yourself.
Upvotes: 5