uiimageview - Load image after the json is parsed and presented -
i know how load image without delaying user.
i have been trying load image url, after view appear , user info showed, when user clicks button view showed without delay.
thanks
use nsurlconnection downloading:
nsurlrequest* req = [nsurlrequest requestwithurl:url]; nsoperationqueue* q = [nsoperationqueue mainqueue]; [nsurlconnection sendasynchronousrequest:req queue:q completionhandler:^(nsurlresponse *resp, nsdata *d, nserror *err) { if (d) { uiimage* im = [uiimage imagewithdata:d]; // image } }];
the download happens on background thread, user not delayed , (most important) main thread not blocked; once download complete, completion handler happens on main thread safe stick image interface or set property or whatever.
Comments
Post a Comment