Krunal
Krunal

Reputation: 6490

Lazy loading issue in UITableView

I have implemented lazy loading in my UITableView,

in which, i am downloading images from server, and server contains images with different sizes..

and displays like this,

: Images getting displayed properly but the problem is UITableViewCell Text is not getting displayed properly align in single line as you can see in the image alignment of UITableViewCell Text is not in the single line

Means:Cell 0 to Cell 4 is displayed properly because server contains images with size of 100*100 for Cell 0 to Cell 4 but alignment of cell 5 and cell 6 is different because server contains image with different size of 85*85

Is there any way in which i can set Text alignment in single line ??

Thanks in advance.

Upvotes: 0

Views: 398

Answers (3)

user2702717
user2702717

Reputation: 1

You can use imageView.contentMode = UIViewContentModeScaleAspectFit;

to adjust the imagview width and height based on image size

Upvotes: 0

user1728855
user1728855

Reputation:

I think Custom TableView Cell will do for you. You can design a cell like below https://www.dropbox.com/s/r9r6dsmdwmpk50h/customcell.png

Upvotes: 0

Nitin Gohel
Nitin Gohel

Reputation: 49720

i Suggest you to use Custom table-cell with One image-view and Label and set Imageview contentMode like bellow

imageView.contentMode = UIViewContentModeScaleAspectFill; //will fill the frame

imageView.contentMode = UIViewContentModeScaleAspectFit;  //will show the entire image, possibly leaving areas of the frame open. 

and your Label set Number of Line 0

Upvotes: 1

Related Questions