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
Post a Comment