ios - hiding / showing of detailTextLabel in uitableview -


i tried hide detailtextlabel.cell while tableview loads,by code,

cell.textlabel.text=[array objectatindex:indexpath.row]; cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row];  cell.detailtextlabel.hidden = yes; 

while selecting row, try display detailarray in didselectrowatindexpath, expected detailarray displaying while pressing row , once stop pressing it, detailarray text disappears, why happening so,

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  [tableview deselectrowatindexpath:indexpath animated:yes]; nslog(@"indexpath %d", indexpath.row); selectedindex = indexpath.row; issearching = yes;  [self.tableview beginupdates]; static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];  cell.textlabel.text=[dealarray objectatindex:indexpath.row]; cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row];  cell.detailtextlabel.hidden = no;   [self.tableview endupdates];    }  - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { if (issearching && indexpath.row == selectedindex) {      return 77;  } return 44;   } 

edited:

assigned variable 'a' in .h file , used code follows,

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; // configure cell... cell.textlabel.text=[dealarray objectatindex:indexpath.row]; cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row];     nslog(@"dealarray %@\n %@",dealarray,detailarray);      if (a==-1) {         cell.detailtextlabel.hidden = yes;      }     else if(a==indexpath.row)     {         cell.detailtextlabel.hidden = no;                }     else cell.detailtextlabel.hidden = yes;  return cell;   }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  [tableview deselectrowatindexpath:indexpath animated:yes]; nslog(@"indexpath %d", indexpath.row); selectedindex = indexpath.row; issearching = yes; static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];  cell.textlabel.text=[dealarray objectatindex:indexpath.row]; cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row]; a=indexpath.row; [tableview reloaddata]; 

}

for this, can use 2 type of cell.

for normal data, use basic cell. on selection, reload table or cell , use detaillabel cell selected row only.

and solve issue.

thanks


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -