ios - How to use multiple cell.textLabel.text for multiple tableview? -


i trying create 2 tableviews 1 single uiviewcontroller, here have created 2 tableview if conditional statement operate separate process separate tables. problem need create separate cell.textlabel.text separate tables. whenever clicked cell getting first tableview cell.textlabel.text value.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      if (tableview==tableone)     {         static nsstring *cellidentifier = @"cell";         cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];          cell.textlabel.text = [....]; // here applying first table values      }     if (tableview==tabletwo) {          static nsstring *cellidentifier = @"cell";         cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];          cell.textlabel.text = [....]; // here applying values      }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  [tableview deselectrowatindexpath:indexpath animated:yes];     if (tableview==tableone) {        uitableviewcell *selectedcell = [tableview cellforrowatindexpath:indexpath];        celltext = selectedcell.textlabel.text;        nslog(@"%@",celltext);    }    if (tableview==tabletwo) {        uitableviewcell *selectedcell = [tableview cellforrowatindexpath:indexpath];        celltext = selectedcell.textlabel.text;        nslog(@"%@",celltext);    }  } 

    can give tag of tableview in utility view.     after giving tag can use tableview using given particular tag.  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      if (tableview.tag == 1)     {         static nsstring *cellidentifier = @"cell";         cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];          cell.textlabel.text = [....];      }     if (tableview.tag ==2) {          static nsstring *cellidentifier = @"cell";         cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];          cell.textlabel.text = [....];     }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  [tableview deselectrowatindexpath:indexpath animated:yes];     if (tableview.tag == 1) {        uitableviewcell *selectedcell = [tableview cellforrowatindexpath:indexpath];        celltext = selectedcell.textlabel.text;        nslog(@"%@",celltext);    }    if (tableview.tag == 2) {        uitableviewcell *selectedcell = [tableview cellforrowatindexpath:indexpath];        celltext = selectedcell.textlabel.text;        nslog(@"%@",celltext);    } } 

// think you..


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -