0

I have embedded my view controller in a navigation controller on my storyboard, then added a table view which I configured from code. I'm trying to make it, when I click a row in the table, it should change the view and putting the subview into the stack, however I can't access the navigation controller.

[self.navigationController pushViewController:disclosureView animated:YES];

When this code launches, it gives the error: " NavController[990:c07] Application tried to push a nil view controller on target . "

Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76
  • This is not an Xcode question. –  Jun 27 '13 at 08:24
  • Are you sure disclosureView is a UIViewController object? – Cosmin Jun 27 '13 at 08:28
  • Why wouldn't it be an Xcode question, when I'm writing it in Xcode and the problem I'm having is not knowing how Xcode names a navigation controller dropped onto the storyboard :| – Lord Zsolt Jun 27 '13 at 08:28
  • It's a UITableViewController. – Lord Zsolt Jun 27 '13 at 08:29
  • Errors says disclosureView (which should be named disclosureViewController to avoid confusions) is nil. Can you show it's initialization? – Tala Jun 27 '13 at 08:30
  • Can you post more code, so we can see how you create your UITableViewController. – Cosmin Jun 27 '13 at 08:31
  • I've simply created a new Objective-C class, UITableViewController subclass, and changed the numberOfSectionsInTableView: to return 1, numberOfRowsInSection to return the number of objects in an array and linked it's delegate and datasource, everything else is left as Xcode generated it. – Lord Zsolt Jun 27 '13 at 08:34
  • Try with **PresentViewController**...? – Kumar KL Jun 27 '13 at 08:43
  • What do you mean by that? PresentViewController undeclared. – Lord Zsolt Jun 27 '13 at 08:45
  • [self.navigationController presentViewController:disclosureView animated:YES completion:nil]; – Kumar KL Jun 27 '13 at 08:47
  • Did that, error: NavController[2344:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target .' – Lord Zsolt Jun 27 '13 at 08:50
  • Ok .. I need to know the way You were doing ..? – Kumar KL Jun 27 '13 at 08:56
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/32462/discussion-between-user2212172-and-kumar-kl) – Lord Zsolt Jun 27 '13 at 08:58

1 Answers1

1

I hope that you didn't get call the ViewController properly :

if(indexPath.row == 0)

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController *disclosureView = [storyboard instantiateViewControllerWithIdentifier:@"disclosureView" ];

        [self.navigationController pushViewController:disclosureView animated:YES];

Here is the screenShot for getting the UIViewController identifier: enter image description here

Kumar KL
  • 15,315
  • 9
  • 38
  • 60