objective c - SDWebImage's sd_setImageWithURL crashes the application when trying to show 100 of images in view -
i showing around 100 of urls in 1 screen asyncronusly in button image sdwebimage.
i facing issues memory load when tried show images url.
i have 1 uiscrollview , in have 1 uiimageview has 100 uibutton added dynamaically.
now requirement when user zoomed int uiscrollview @ level need show image in uibutton , when start show image server button following code crashes witht memory warning.
[btn sd_setimagewithurl:[nsurl urlwithstring:busowner.whitelargelogourl] forstate:uicontrolstatenormal placeholderimage:[uiimage imagenamed:placeholderimage]];
can 1 please let me know how can resolve memory issues , can show images @ same time 100 buttons?
i have tried put uiiamgeview instead of uibutton , have tried use
dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0ul); dispatch_async(queue, ^{ // perform non main thread operation (businessownerentity *busowner in arrbusowner) { nsurl *url = [nsurl urlwithstring:busowner.whitelargelogourl]; sdwebimagemanager *manager = [sdwebimagemanager sharedmanager]; [manager downloadimagewithurl:url options:sdwebimageprogressivedownload progress:^(nsinteger receivedsize, nsinteger expectedsize) { nslog(@"recieved file %ld",(long)receivedsize); } completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, bool finished, nsurl *imageurl) { }]; } dispatch_sync(dispatch_get_main_queue(), ^{ // perform main thread operation }); });
to download images before crashes here too..
use sdwebimage
callbacks load images in queue, not @ same time.
reduce memory consumption , avoid ios kill app.
[manager downloadimagewithurl:url options:sdwebimageprogressivedownload progress:^(nsinteger receivedsize, nsinteger expectedsize) { nslog(@"recieved file %ld",(long)receivedsize); } completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, bool finished, nsurl *imageurl) { if ("are less 10 images loading?"){ [self startnewimageloading]; } }];
Comments
Post a Comment