Read Q
Read Q

Reputation: 1515

Segue Not performed

I have a login view controller at the start of the app. Then once the user login is successful I am taking the user to a view which has a table view inside it. I have embedded the table view inside a navigation controller. I have a segue which pushes user to the detail view. However as soon as I click on the row cell, I get the following error.

'Could not find a navigation controller for segue 'Event Details'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.''

But as I said above, there is a navigationview controller which embeds the table view. Whats causing this error?

the flow of the app is as follows

'->Login View     NavigatinViewController->(View with a table View inside)->Details'

Upvotes: 1

Views: 1691

Answers (2)

Paras Joshi
Paras Joshi

Reputation: 20551

I think here you not use UINavigationController as a RootViewController.. and you use UIViewController as a rootViewController.. so may be this problem with this error

Just try to Follow this steps for the output..

  1. Drag a new navigation controller into your storyboard - it will by default be attached to a tableview controller

  2. Delete the tableview controller Right click on the navgiation controller, and connect the "Root View Controller" property to your existing view controller

  3. Move the entry point arrow from your view controller to the root view controller

UPDATE:

see this example which through you can put validation and clearly push in your detailview...

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"AddPlayer"])
    {
        UINavigationController *navigationController = 
          segue.destinationViewController;
        PlayerDetailsViewController 
          *playerDetailsViewController = 
            [[navigationController viewControllers] 
              objectAtIndex:0];
        playerDetailsViewController.delegate = self;
    }
}

Upvotes: 1

Bill
Bill

Reputation: 311

That looks like you may be missing a view controller.

Specifically, you should have something that resembles:

Login View > Navigation Controller > Table View Controller > Detail View Controller

Assuming you are creating a storyboard, the navigation controller can be easily added by selecting the table view controller and choosing Editor > Embed in > Navigation Controller.

Alternatively, if you want the navigation controller solely for a table view that is embedded within a view controller object, I recommend creating a container view in the view controller to display the table view and associated navigation controller.

To accomplish the latter, drag a container object into the view controller and size it to fit the table view that you want to display. Delete the view controller that the container view automatically creates.

Next, create a table view controller and segue to it from the container view. This segue will be an 'embed' segue. Lastly, you can then embed the table view controller you just created in a navigation controller and add the push segue from the table view controller to the detail view controller.

Upvotes: 1

Related Questions