we using - (uitableviewcell *)cellforrowatindexpath:(nsindexpath *)indexpath; method retrieve cell @ specific index path. - (uitableviewcell *)cellforrowatindexpath:(nsindexpath *)indexpath return object representing cell of table or nil if cell not visible or indexpath out of range. repeating calls - (uitableviewcell *)cellforrowatindexpath:(nsindexpath *)indexpath causes nsrange exception. can reason?
nsindexpath *ip = [nsindexpath indexpathforrow:index insection:0]; customcell *cell = (customcell *)[tableview_ cellforrowatindexpath:ip]; code
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { customcell *cell = nil; static nsstring *cellidentifier = @"cell"; cell = (customcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { nsarray *nibs = [[nsbundle mainbundle] loadnibnamed:@"customcell" owner:self options:nil]; cell = [nibs objectatindex:0]; } imagecache *imagecache = [[imagecache alloc]initwithurl:sentcard.sentimage]; uiimage *cachedimage = [imagecache fetchimagefromcache]; if (cachedimage!=nil) { cell.cardimage.image = [utility scaleimagetosize:cell.cardimage.frame.size image:cachedimage]; [cell.loadingindicator stopanimating]; } else { imagecache.cachedelegate = self; imagecache.cacheduration = 24.0; [imagecache fetchimage]; } return cell; }
you asking cell not being created yet. example, should crash on first cell (index 0). should ask cell (aka cellforrowatindexpath) once table being populated.
Comments
Post a Comment