DidSelectRowAtIndexPath使用故事板

时间:2014-02-23 20:04:35

标签: ios uitableview didselectrowatindexpath

在我的应用程序中,我使用以下的didSelectRowAtIndexPath方法转到viewController,但我在一个故事板中工作,并抛出异常告诉我找不到nib文件。我应该如何更改方法以无异常地打开新的viewController?:

//link to the next view

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    EmpresasTableViewController *detailViewController = [[EmpresasTableViewController alloc] initWithNibName:@"EmpresasTableViewController" bundle:nil];
    detailViewController.title =[[categorias objectAtIndex:indexPath.row]objectForKey:@"idCategoria"];
    detailViewController.categoriaDescription = [categorias objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:detailViewController animated:YES];
}

1 个答案:

答案 0 :(得分:2)

你必须为你的故事板中的ViewController制作一个标识符(例如detailViewController),然后像这样实例化你的EmpresasTableViewController

EmpresasTableViewController *detailViewController =[self.storyboard instantiateViewControllerWithIdentifier:@"detailViewController"];

我希望能帮到你

相关问题