ios - Scrolling is not proper When i used SDWebImage -
i have serious problem of scrolling table.
initially used gcd loading image in background , setting on table cell. table not scrolling smoothly. used sdwebimage same thing happening.
could let me know reason this. why table scrolling not smooth expected.
please let me know views app waiting release same purpose.
code :
-(uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ nsstring *cellidentifier = @"cell"; customcellforexhibitor *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { nsarray *xibpath = [[nsbundle mainbundle]loadnibnamed:@"customcellforexhibitor" owner:self options:nil]; (id fileobject in xibpath) { cell = (customcellforexhibitor*)fileobject; } } objdatamodel = [parserdatacontentarray objectatindex:indexpath.section]; cell.exhibitornamelabel.text = [objdatamodel exhibitornameobjectclass]; cell.exhibitortext.text = [objdatamodel exhibitorofferobjectclass]; cell.exhibitorsponsortype.text = [objdatamodel exhibitorsponsortypeobjectclass]; [cell.exhibitorsponsortype settextalignment:nstextalignmentright]; // #pragma mark gcd; // // nsstring *imageurl = [[parserdatacontentarray objectatindex:indexpath.section] exhibitorimageobjectclass]; //// nsdata *imagedata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:imageurl]]; //// cell.exhibitorimage.image = [uiimage imagewithdata:imagedata]; // // dispatch_queue_t concurrentqueue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); // //this start image loading in bg // dispatch_async(concurrentqueue, ^{ // nsdata *imagedata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:imageurl]]; // // //this set image when loading finished // dispatch_async(dispatch_get_main_queue(), ^{ // // cell.exhibitorimage.image = [uiimage imagewithdata:imagedata]; // [cell setneedsdisplay]; // // }); // }); nsstring *imageurl = [[parserdatacontentarray objectatindex:indexpath.section] exhibitorimageobjectclass]; [cell.exhibitorimage setimagewithurl:[nsurl urlwithstring:imageurl] placeholderimage:[uiimage imagenamed:@"placeholder.png"]]; if ([cell.exhibitorsponsortype.text isequaltostring:@"gold"]) { cell.exhibitorsponsortype.textcolor = [uicolor colorwithred:255/255.0 green:215/255.0 blue:0 alpha:1]; } else if ([cell.exhibitorsponsortype.text isequaltostring:@"silver"]){ cell.exhibitorsponsortype.textcolor = [uicolor colorwithred:192/255.0 green:192/255.0 blue:192/255.0 alpha:1]; } else cell.exhibitorsponsortype.textcolor = [uicolor colorwithred:229/255.0 green:228/255.0 blue:226/255.0 alpha:1]; return cell; }
thank best regards.
use lazy loading file instead here reference u can find here along demo how implemented.
https://stackoverflow.com/a/18032907/1305001
[cell addsubview:[self addviewwithurl:imageurl nframe:cgrectmake(0, 0, 50, 50)]];
add method below cellforrow
-(uiview*)addviewwithurl:(nsstring*)urlstr nframe:(cgrect)rect { lazyload *lazyloading; lazyloading = [[lazyload alloc] init]; [lazyloading setbackgroundcolor:[uicolor graycolor]]; [lazyloading setframe:rect]; [lazyloading loadimagefromurl:[nsurl urlwithstring:urlstr]]; return lazyloading; }
set placeholder in lazyload.m file's init method as
-(id)init{ if (self==[super init]) { [self setimage:[uiimage imagenamed:@"placeholder.png"]]; } return self; }
and change superclass of lazyload.h file uiimageview uiview
@interface lazyload : uiimageview
Comments
Post a Comment