2014-02-23 33 views
0

在我的應用程序中,我使用下面的didSelectRowAtIndexPath方法去viewController,但我正在一個故事板內工作,並且拋出一個異常,告訴我找不到該nib文件。我應該如何改變方法來打開新的viewController,而無需在故事板例外?:DidSelectRowAtIndexPath使用故事板

//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]; 
} 
+0

你必須做出一個標識符(detailViewController例如)爲您的ViewController在你的故事板,然後實例你這樣的EmpresasTabl eViewController EmpresasTableViewController * detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@「detailViewController」]; – chawki

+0

@chawki,請將您的評論置於答案中,您的評論有效......謝謝。 – mvasco

回答

2

你必須做出一個標識符(detailViewController例如)爲您的ViewController,然後實例你這樣的EmpresasTableViewController

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

我希望幫助您

+0

謝謝你......你的答案正如你期望的那樣工作...... – mvasco