iphone - Custom UITableViewCell imageView not updating after setImage -
i've got custom uitableviewcell class model object performs asynchronous download of image displayed in cell. know i've got outlets connected in ib widgettvc, know image data being returned server, , i've alloc/init'd widget.logo uiimage too. why image blank in tableviewcell? in advance.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { widget *thewidget = [widgetarray objectatindex:indexpath.row]; static nsstring *cellidentifier = @"widgetcell"; widgettvc *cell = (widgettvc*)[self.tableview dequeuereusablecellwithidentifier:cellidentifier]; if(cell == nil) { [[nsbundle mainbundle] loadnibnamed:@"widgettvc" owner:self options:nil]; cell = self.widgettvc; self.widgettvc = nil; } [cell configurewithwidget:thewidget]; return cell; }
in widgettvc class, have following method:
- (void)configurewithwidget:(widget*)awidget { self.widget = awidget; self.namelbl.text = awidget.name; [self.logoivw setimage:awidget.logo]; // logoivw image view logo }
finally- i've got callback method sets logo uiimage property on widget model object asynchronously (simplified):
(void)didreceiveimage:(asihttprequest *)request { // pass ref widget's logo uiimage in userinfo dict uiimage *animage = (uiimage*)[request.userinfo objectforkey:@"image"]; uiimage *newimage = [uiimage imagewithdata:[request responsedata]]; animage = newimage; }
in didreceiveimage:
, you're modifying local pointer animage
. need set image
property of uiimageview
in order update gets displayed. instead of stashing reference widget's uiimage
, pass reference uiimageview
, , in didreceiveimage:
like
uiimageview *imageview = (uiimageview*)[request.userinfo objectforkey:@"imageview"]; uiimage *newimage = [uiimage imagewithdata:[request responsedata]]; imageview.image = newimage;
Comments
Post a Comment