uiimageview - iOS UIImage Passes Old Image -
in app, im using api images server. using below code, gets images in order of size replace better quality.
dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ nsurl *imageurl = [nsurl urlwithstring: [nsstring stringwithformat:@"%@", [[[self.information objectforkey:@"images"]objectforkey:@"normal"] description]]]; nsdata *imagedata = [nsdata datawithcontentsofurl:imageurl]; self.shotimage = [uiimage imagewithdata:imagedata]; self.image.image = self.shotimage; }); dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ nsurl *imageurl = [nsurl urlwithstring: [nsstring stringwithformat:@"%@", [[[self.information objectforkey:@"images"]objectforkey:@"hidpi"] description]]]; nsdata *imagedata = [nsdata datawithcontentsofurl:imageurl]; uiimage *image = [uiimage imagewithdata:imagedata]; self.image.image = self.shotimage; });
also, if press on image takes viewcontroller image fullscreen.
however, if wait high quality 1 load before tap on it, in prepareforsegue method, still passes original low quality version.
see code below prepareforsegue
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { fullsizeimageviewcontroller *vc = [segue destinationviewcontroller]; uiimage *img = [[uiimage alloc] init]; img = self.shotimage; vc.shotimage = img; }
dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ nsurl *imageurl = [nsurl urlwithstring: [nsstring stringwithformat:@"%@", [[[self.information objectforkey:@"images"]objectforkey:@"hidpi"] description]]]; nsdata *imagedata = [nsdata datawithcontentsofurl:imageurl]; uiimage *image = [uiimage imagewithdata:imagedata]; self.image.image = self.shotimage; });
in code looks miss line:
self.shotimage = [uiimage imagewithdata:imagedata];
Comments
Post a Comment