ios - UITableView scrolls slow after downloading cell images -


i trying download thumbnail server , display them in each cell :

// displaying image... dictionary = [newsfeed objectatindex:indexpath.row]; uiimage *image = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:[dictionary objectforkey:@"image"]]]]; cell.imageview.image = [image imagescaledtosize:cgsizemake(55, 55)];     

but after downloading , displaying images, table view scrolls slowly!

the main problem [nsdata datawithcontentsofurl:] method synchronous request. blocks thread running until request done.

you should avoid type of interaction if run on main thread. thread frozen , user disappointed ;)

you have many solutions this. simple 1 use third library sdwebimage or afnetworking.

both have categories around uiimageview class allows use them in simple manner. example, using uiimageview+afnetworking should following:

[cell.imageview setimagewithurl:yoururl placeholderimage:yourplaceholderimage]; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -