Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewController不是';t传递数据_Ios_Uiviewcontroller_Uitableview - Fatal编程技术网

Ios UITableViewController不是';t传递数据

Ios UITableViewController不是';t传递数据,ios,uiviewcontroller,uitableview,Ios,Uiviewcontroller,Uitableview,我试图在UITableViewController之间传递数据,该控制器显示为: SeleccionBundesligaViewController *seleccionBundesligaVC = [[SeleccionBundesligaViewController alloc]initWithStyle:UITableViewStylePlain]; seleccionBundesligaVC.title = @"1.Bundesliga"; [self.navigationContro

我试图在UITableViewController之间传递数据,该控制器显示为:

SeleccionBundesligaViewController *seleccionBundesligaVC = [[SeleccionBundesligaViewController alloc]initWithStyle:UITableViewStylePlain];

seleccionBundesligaVC.title = @"1.Bundesliga";
[self.navigationController pushViewController:seleccionBundesligaVC animated:YES];
当我选择一行时,它将通过以下方式关闭:

- (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"]];

}

但是,当我选择行时,它不会将数据传递给“infoPartidaVC”。

我认为您的问题在于,您正在显示标签之前设置标签的文本。
请看我回答的问题

您最好在SeleccionBundesligaViewController的.h文件中创建一个属性:

@property (weak, nonatomic) InformacionPartidaViewController *infoPartidaVC;
创建UITableViewController时,在推送它之前,添加引用:

SeleccionBundesligaViewController *seleccionBundesligaVC = [[SeleccionBundesligaViewController alloc]initWithStyle:UITableViewStylePlain];

seleccionBundesligaVC.title = @"1.Bundesliga";
seleccionBundesligaVC.infoPartidaVC = self;
[self.navigationController pushViewController:seleccionBundesligaVC animated:YES];
然后,在UITableViewController中的didSelectRowAtIndexPath中:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = [equipos objectAtIndex:indexPath.row];

    [self.navigationController popViewControllerAnimated:YES];
    [self.infoPartidaVC.labelNombreEquipo setText:[dic objectForKey:@"nombre"]];
}

如何初始化?在infoPartidaVC上创建一个NSString属性,设置didSelectRowatineXpath中的值,在infoPartidaVC的viewDidLoad中使用该字符串设置标签