ios - UITableViewController isn't passing data -
i trying pass data between uitableviewcontroller showed with:
seleccionbundesligaviewcontroller *seleccionbundesligavc = [[seleccionbundesligaviewcontroller alloc]initwithstyle:uitableviewstyleplain]; seleccionbundesligavc.title = @"1.bundesliga"; [self.navigationcontroller pushviewcontroller:seleccionbundesligavc animated:yes];
and when select row it's closed by:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nsdictionary *dic = [equipos objectatindex:indexpath.row]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:[nsbundle mainbundle]]; informacionpartidaviewcontroller *infopartidavc = [storyboard instantiateviewcontrollerwithidentifier:@"infopartidavc"]; [self.navigationcontroller popviewcontrolleranimated:yes]; [infopartidavc.labelnombreequipo settext:[dic objectforkey:@"nombre"]]; }
but when select row, doesn't pass data 'infopartidavc'.
your best bet create property in seleccionbundesligaviewcontroller's .h file:
@property (weak, nonatomic) informacionpartidaviewcontroller *infopartidavc;
when create uitableviewcontroller , before push it, add reference:
seleccionbundesligaviewcontroller *seleccionbundesligavc = [[seleccionbundesligaviewcontroller alloc]initwithstyle:uitableviewstyleplain]; seleccionbundesligavc.title = @"1.bundesliga"; seleccionbundesligavc.infopartidavc = self; [self.navigationcontroller pushviewcontroller:seleccionbundesligavc animated:yes];
then, in didselectrowatindexpath in uitableviewcontroller:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nsdictionary *dic = [equipos objectatindex:indexpath.row]; [self.navigationcontroller popviewcontrolleranimated:yes]; [self.infopartidavc.labelnombreequipo settext:[dic objectforkey:@"nombre"]]; }
Comments
Post a Comment