ios - I had 1 table view and three labels in it -
here problem had table view consists of 3 three labels in (test1, test2, test3) comes webservice. want load 3 labels in single table view. here code below :
for (nsdictionary *entry in entries) { projectnames = [entries valueforkey:@"nm_project"]; tasknames = [entries valueforkey:@"task_name"]; subtasknames = [entries valueforkey:@"subtask_name"]; } nslog(@"project : %@", projectnames); nslog(@"tasknames : %@", tasknames); nslog(@"subtask : %@", subtasknames); - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { #warning potentially incomplete method implementation. // return number of sections. return 1; } -(nsinteger) tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [projectnames count]; } -(uitableviewcell*) tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *identitifier = @"cell"; dlptstableviewcell * cell = [tableview dequeuereusablecellwithidentifier:identitifier forindexpath:indexpath]; long row = [indexpath row]; cell.textlabel.text = projectnames[row]; cell.textlabel.text = tasknames[row]; cell.textlabel.text = subtasknames[row]; return cell; }
i want load test 1 in projectnames array, test 2 in tasknames array , test 3 in subtasks arrays..
please me out.
if creating custom uitableviewcell name "dlptstableviewcell" first create 3 labels i.e yourlabel1, yourlabel2, yourlabel3 , use below code :
-(dlptstableviewcell *)getnewcell { nsarray *toplevelobjects = [[nsbundle mainbundle] loadnibnamed:@"dlptstableviewcell" owner:nil options:nil]; dlptstableviewcell *cell; (id currentobject in toplevelobjects) { if ([currentobject iskindofclass:[dlptstableviewcell class]]) { cell= (dlptstableviewcell *)currentobject; return cell; } } return nil; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"customcell"; dlptstableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [self getnewcell]; } // displaying values cell.yourlabel1.text = first value; cell.yourlabel2.text = second value; cell.yourlabel3.text = third value; return cell; }
Comments
Post a Comment