ios - Programming tableviews segue drill down -
i trying convert apps storyboards. data stored in plist file , drill down through tableviews using following code in current didselectrowatindexpath:
method:
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nsdictionary *dictionary = [self.tabledatasource objectatindex:indexpath.row]; nsarray *children = [dictionary objectforkey:@"children"]; [tableview deselectrowatindexpath:indexpath animated:yes]; if ([children count] == 0) { nsstring *tempstring1 = [dictionary valueforkeypath:@"movie"]; nsstring *tempstring2 = [dictionary valueforkeypath:@"text"]; nsstring *tempstring3 = [dictionary valueforkeypath:@"diagram"]; detailsvc *dvc = [[detailsvc alloc] initwithnibname:@"detailsvc" bundle:nil]; dvc.movie = tempstring1; dvc.pdfdesc = tempstring2; dvc.pdfdiagram = tempstring3; dvc.navigationitem.title = [dictionary valueforkeypath:@"title"]; [self.navigationcontroller pushviewcontroller:dvc animated:yes]; } else { levelsvc *lvc = [[levelsvc alloc] initwithnibname:@"levelsvc" bundle:[nsbundle mainbundle]]; lvc.currentlevel += 1; lvc.navigationitem.title = [dictionary valueforkeypath:@"title"]; [self.navigationcontroller pushviewcontroller:lvc animated:yes]; lvc.tabledatasource = children; }
my question is: how on earth convert method use segues , storyboards? can create segue detailviews, , there million tutorials on net, cannot figure out how drill down through data in tableview.
any or sample code appreciated!
you can use -performseguewithidentifier:sender:
transition 1 view controller programmatically. move code configures dvc
-prepareforsegue:sender:
implementation.
another option connect segue in storyboard cell in table next view controller. cause segue triggered row selected, prevents having start segue programmatically @ all. in case, implement -prepareforsegue:sender:
set necessary data in segue's destination view controller. sender
parameter table cell tapped, , can use find selected row.
Comments
Post a Comment