سؤال

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];
}
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top