objective c - One TableViewController with 2 sections linking to 1 DetailView? -
so in project have 1 historytableviewcontroller contains 2 sections. 1 section peopleyouowe , other section group of peoplewhooweyou. how able hook 1 tableviewcontroller , link detail view display different data according sections?
try below approach using prepareforsegue -
creat tableview outlet named mytableview
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. nsindexpath *path = [self.mytableview indexpathforselectedrow]; if (path.section == 0) { if ([segue.identifier isequaltostring:@"peopleyouowe"]) { peopleyouowe *peopleyouowevc = segue.destinationviewcontroller; // can data of cell array[path.row] } } else if (path.section == 1) { if ([segue.identifier isequaltostring:@"peoplewhooweyou"]) { peoplewhooweyou *peoplewhooweyou = segue.destinationviewcontroller; // can data of cell array[path.row] } } }
Comments
Post a Comment