should I resize images for displaying in a UITableView? - ios

I am using a tableView that among other things display images in a UITableViewController. The images are locally stored and quite large so that they may if clicked be displayed full screen. The tableView cell has a small preview of these images.
When storing these images locally, is it better to store two versions? A thumbnail and a full image purely for the performance of the tableView? Or will that not effect the scrolling etc to have just the one full image and allow the tableView cell to resize the image to display at the reduced size?
I will not be uploading/downloading so this question is not about creating thumbnails to optimize download transfers.
I am just interested in whether it is best practice to create a thumbnail for tableView controller cell's.
Also, I am familiar with setting aspectFit for the imageView to get the correct size. Just wondering if I should be carrying two images for better performance or if it doesn't make any difference and not necessary to do that.

I am just interested in whether it is best practice to create a thumbnail for tableView controller cells
Yes! It is best practice to create a thumbnail for any image display, especially table view cells. To hand an image view an image that is too large is a massive waste of memory and other resources.
See Image and Graphics Best Practices from WWDC 2018 for details.

Related

How to create a collection view with images that change size on scroll

I want to implement an horizontal collection view displaying images that increases the size of the images with a smooth animation as they approach the center and reduces their size as they move away.
I have been studying the UICollectionView potentials but so far I have not been able to understand if such behaviour is possible to be implemented using UICollectionView or what would be the best alternative. For instance using UIScrollView instead (with a lot more work probably).
Some guidance or sample code would be most welcome. Thank you.

IOS display tile view images in UITableView

I have 10 images and their description. I have to display it in UITableView. I want to display
those images in tile view. I am using this library. Here in the sample snap these 5 images are displaying in 2 cells. But i want that, all those images will display in just 1 cell. How can I do that?
Please Help
UICollectionView is the way to go.
UICollectionView takes the familiar patterns of UITableView and generalizes them to make any layout possible. In your case it will be fairy simple. You will use a standard built-in flow layout to place the tiles with pictures.

Better to use a small image that resizes or true sized image for UITableViewCell background?

I'm trying to address a slow scrolling and slow loading UIViewController that uses a UITableView with custom background cells.
When I don't set the backgroundView of the cell with an image, the performance is great. So I'm wondering if it's more performant to supply the backgroundView with images that are the actual size of my tableview row or is it better to use smaller images that are resized to fit the row's dimensions?
The images are all local and already included in the app - there's no remote fetching involved.
Improving load time of UITableView that has cells with custom background images
Try to look to use an NSOperationQueue to handle lazy loading of images and a custom tableviewcell.
Google for tweetie custom tableviewcell That should set you in the right direction.
Apple has a sample project for downloading images in tableViews: LazyTableImages

How to speed up the tableview's performance with many images?

I've developing an iPad app.And I have a uitableview, in which every cell has about four to five images.And almost four to five cells on screen.
So there are about 20~30 images on screen.
The images are not very large , perhaps 200*200.(already some kind of thunbnail)
All the images are local resource.
The problem is that when first scroll down the tableview, it needs to load new cells and of course the images in the cells. This makes the UI become laggy.
But when you scroll back up ,it's very smooth. I know this is because UIImage class will cache some images.when scroll back up, the images are cached, so it's smooth.
So my question is how to deal with this?
1.Make as small thumbnail as possible?
2.Pre-load some image?(How?)
3.Use custom cache?(also how?)
I would recommend fetching the images with GCD. I would also subclass the UITableViewCell and in it's drawRect: draw all pictures on the view's layer. That will increase your performance dramatically.
If there is not so much images in the table - you can precache by loading them, when the view is created. Otherwise use more generic approach with async loading in background thread.

iOS UITableView cell layout questions

I have a chat on a web site that looks like this.
I am now building an iPhone app for this and have some problems creating the same layout. I hope you can point me in the right direction. Is subviews or webviews the best choice?
If using UIView, UILabel and UIImage, what is the best way to make rounded corners and the little arrow. The gradient background should not scroll with the table view. What's the easiest way to calculate the hight of each message? What is the best way to async load the images over http?
If using a webview, what is the best way to populate it with data? Building string? Having a template and populate the image, username, time and message thru JavaScript? How can I resize the UITableCell and UIWebView to fit the contests?
Will a table full of UIWebView be much slower than using labels? Will I need to create it twice to return the height of the cell in heightForCellAtIndexPath and add it in cellForRowAtIndexPath?
Thanks for your help!
If you wish to see it live, visit www.aktieguiden.com
This is really a lot more than two questions, and I'll answer several of them.
I would use a table view with a resizable UIImage and a UITextView for each bubble. Use an image of the bubble in png with a transparent background, and make it resizable. Import it with UIImage's -(UIImage*)resizableImageWithCapInsets:(UIEdgeInsets)capInsets. To determine a height, UITextView has a contentSize property which will tell you the size of the view that can be scrolled. For asynchronous loading, use one of the many tutorials or frameworks for that purpose. Here is one:
http://developers.enormego.com/view/what_if_images_on_the_iphone_were_as_easy_as_html

Resources