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

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -