1

I'm trying to navigate from a UIViewController to a UITableViewController with this action button. Obviously I'm doing something wrong so it's missing the UINavigationController linked to the UITableViewController in my storyboard. Or something like that. This code displays the TableView when I press the button, but navigation bar is missing so there's no way of going back and if I swipe through the tableview the app crashes.

-(IBAction)nextButtonPressed:(id)sender{

    ResultsTableViewController *nextController = [[self storyboard] instantiateViewControllerWithIdentifier:@"Results Controller"];
    nextController.objectsArray = resultObjectsArray;
    [self presentModalViewController:nextController animated:YES];
    [nextController release];
}

Should I link the UINavigationController with the UIViewController instead of the UITableViewController, will that work? Or should I target the code above for the UINavigationController instead? How to do this simple thing? Thanks.

EDIT 1:

Adding the Navigation Controller to the UIViewController instead and push to the TableView with it like this:

[self.navigationController presentModalViewController:nextController animated:YES]

didn't solve the issue. It still crashes when swiping.

EDIT 2:

If I do like this:

[self.navigationController pushViewController:nextController animated:YES]

it crashes once the tableview is visible on screen. I get a glance at the navigation bar with "back" button now though. This is crash report from this:

-[__NSCFType isViewLoaded]: unrecognized selector sent to instance. Rødvinsguiden[318:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType isViewLoaded]: unrecognized selector sent to instance 0x6b9d2e0'

1 Answer 1

1

you're forgetting to push WITH the navigationController of your current view, instead your just pushing the new viewController without it.

[self.navigationController presentModalViewController:nextController animated:YES]
Sign up to request clarification or add additional context in comments.

4 Comments

It kind of made it but still it's not functioning properly, even when I added a navigation controller to the tableview as well something isn't right.. I can't get a navigation bar and it still crashes and acts weird, specially if it's more cells than length of screen.
instantiateViewControllerWithIdentifier:@"Results Controller" Why is there a space in the identifiers name? there shouldnt be a space there...
Edited the question with the log from crash, hope if it's enough to see the prob. Btw the "Results Controller" was just a little mistake, fixed that but didn't solve my issue, though..
forget it, this fixed the navigation problem, it was an array I am passing through with it who caused the crash now. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.