问题
In my app I am using the following didSelectRowAtIndexPath method to go to a viewController, but I am working within an story Board, and an exception is thrown telling me that the nib file is not found. How should I change the method to open the new viewController without exceptions?:
//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:
you have to make an identifier (detailViewController for example)for you ViewController in your storyboard and then instantiate like this your EmpresasTableViewController
EmpresasTableViewController *detailViewController =[self.storyboard instantiateViewControllerWithIdentifier:@"detailViewController"];
i hope that help you
来源:https://stackoverflow.com/questions/21973793/didselectrowatindexpath-using-a-story-board