开发者

How do I push another viewController onto the navigationController from within a tabviewController?

I have a project set up using these two tutorials and the link for the second tutorial is at the bottom of the first.

The tutorial is slightly outdated but I managed to get it to work as advertised.Now I want to push a new detailedView onto the NavigationController when a user touches a row in the table view.

So I have added this to my MyTableViewController.m file.

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.

     SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController.xib" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.

     [self.navigationController pushV开发者_运维百科iewController:detailViewController animated:YES];
     [detailViewController release];
}

Now when I run this project and touch a row in my table view I am getting an error:

asm_Terminating_due_to_uncaught_exception

IT seems to be having an issue loading the SecondViewController from nib, however I checked the detailViewController and it is not nil.

I know I am missing something and it is more than likely something simple.

Please help.


Ok so as I said I was missing something simple the fix was to remove the .xib from the nib name.

//change line SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController.xib" bundle:nil];
//to
 SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜