user339946
user339946

Reputation: 6119

More memory efficient way of displaying images in iOS?

I have a photo collage app that takes a bunch of photos from a user's facebook/instagram/library, and draws a bunch of them onto the UIView. To control the amount, there is a slider tool that calculates density (for example, every 150px wide, add an image). I'm running into memory issues after lots and lots of UIImageViews are being added.

Is there some better, more efficient way of showing images onto the screen?

Upvotes: 1

Views: 357

Answers (1)

Richard Brown
Richard Brown

Reputation: 11436

Why not use a UICollectionView. It's designed to present a group of objects (including images) in a manner similar to UITableVIew. Like a TableView memory is automatically managed by the controller.

See the documentation for more information.

You didn't make it clear in your question exactly how you're using this set of images. An alternative is to draw the images into the graphic context using Core Graphics. This will draw the images into a single view instead of into several views. There's only one bitmap to keep in memory. See Drawing a PNG Image Into a Graphics Context for Blending Mode Manipulation for an example.

Upvotes: 5

Related Questions