ios - UIImage setImage is very, very slow -
i'm trying load image local url using following:
uiimage *image = [uiimage imagewithdata:[nsdata datawithcontentsofurl:fileurl]]; [self.imageview setimage:image]; nslog(@"imageview set"); so see in console "imageview set" immediately, takes long time reflected in ui (sometimes few minutes!).
any idea why happening?
this happened me when setting image in background thread (in downloading image file). make sure code run in main thread. image change immediately.
// in background thread... uiimage *image = ... // build or download image dispatch_async(dispatch_get_main_queue(), ^{ [self.imageview setimage:image]; // run in main thread (ui thread) });
Comments
Post a Comment