ios - How to change `UIImageView` in custom cell in `UITableView` -


i have uiimageview in custom cell in uitableview , in want change image in didselectrowatindexpath

it's working uiimageview outside uitableview, not working inside it.

i using code..

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     nsstring *string = [[self.itemsintable objectatindex:indexpath.row] objectforkey:@"name"];     expandcell *cell = [self.menutableview dequeuereusablecellwithidentifier:@"cell"];     uiimage *image;      if ([string isequaltostring:@"news"]) {          if ([[self.viewimage image] isequal:[uiimage imagenamed:@"down-arrow.png"]]) {             nslog(@"down");             image = [uiimage imagenamed:@"up-arrow.png"];          } else {             nslog(@"up");             image = [uiimage imagenamed:@"down-arrow.png"];         }          cell.imgexpand.image = image;         self.viewimage.image = image;      } } 

how can fix that?

first assign tag number uiimageview (say 10). write code in didselectrowatindexpath method

uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; uiimageview *yourimageview = (uiimageview*)[cell viewwithtag:10];//replace yourimageview name of uiimageview on custom cell  //--------- code ------ nsstring *str = [[self.itemsintable objectatindex:indexpath.row] objectforkey:@"name"]; uiimage *image;  if ([str isequaltostring:@"news"]) {      if ([[self.viewimage image] isequal:[uiimage imagenamed:@"down-arrow.png"]])      {         nslog(@"down");         image = [uiimage imagenamed:@"up-arrow.png"];      }     else {         nslog(@"up");         image = [uiimage imagenamed:@"down-arrow.png"];     }      [yourimageview setimage:image];     [self.viewimage setimage:image]; } 

i think resolve problem.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -