ios - Loading Issues with UITableViewCell -



ios - Loading Issues with UITableViewCell -

loading gifs uitableviewcell using sdwebimage. it's fast, tableview doesn't seem load until user scrolls tableview.

any suggestions how prepare issue?

this uitableview

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // homecoming number of rows in section. homecoming self.gifarray.count; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *myidentifier = @"cell"; rdgifgridtableviewcell *cell = (rdgifgridtableviewcell *)[tableview dequeuereusablecellwithidentifier:myidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"rdgifgridtableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; } cell.urllabel.text = [self.gifarray objectatindex:indexpath.row]; cell.urllabel.textcolor = [uicolor clearcolor]; [cell.imageview sd_setimagewithurl:[nsurl urlwithstring:cell.urllabel.text] placeholderimage:nil options:sdwebimagecachememoryonly]; homecoming cell; }

this how add together content array occurs in viewdidload:

nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:urlstring]]; nsoperationqueue *queue = [[nsoperationqueue alloc] init]; [nsurlconnection sendasynchronousrequest:request queue:queue completionhandler:^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { nsdictionary *json = [nsjsonserialization jsonobjectwithdata:data options:0 error:nil]; nsarray *idarray = [json objectforkey:@"data"]; (nsdictionary *ids in idarray) { nsdictionary *images = ids[@"images"]; nsdictionary *fixedheightimage = images[@"fixed_width"]; self.gifurl = fixedheightimage[@"url"]; [self.gifarray addobject:self.gifurl]; [self.tableview reloaddata]; }

the next line might problem

static nsstring *myidentifier = @"cell";

when cells beingness reused using different cellidentfier rdgifgridtableviewcell.

it should same cell beingness reused.

so prepare line , utilize variable 1 time again when it's nil avoid such mistake, oh , while you're @ it, consider renaming variable first letter lowercase myidentifier objective c naming convention suggests.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *myidentifier = @"rdgifgridtableviewcell"; rdgifgridtableviewcell *cell = (rdgifgridtableviewcell *)[tableview dequeuereusablecellwithidentifier:myidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"rdgifgridtableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; } cell.urllabel.text = [self.gifarray objectatindex:indexpath.row]; cell.urllabel.textcolor = [uicolor clearcolor]; [cell.imageview sd_setimagewithurl:[nsurl urlwithstring:cell.urllabel.text] placeholderimage:nil options:sdwebimagecachememoryonly]; homecoming cell; }

ios objective-c uitableview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -