2
votes

I'm trying to set up a basic "Newsfeed" function for an iOS app, with headlines in a TableViewController segueing into a simple ViewController to display the text of the selected story. I'm using Storyboards to set up the segues, and I can't get it to work...

What I've Done - I started by CTRL+Dragging from the Cell of the TableView onto the secondary ViewController and choosing "Selection Segue - Push." Then I clicked on the segue and gave it the identifier "newsArticleSegue," and I embedded the TableView in a Navigation Controller. I've got the TableView data source hooked up to a plist file as well, although I don't think that would have any effect on the segue, right?

All that happens when I run the app and click on a row of the TableView is that it gets highlighted blue. Clearly the segue isn't working, but the tutorials I've found only list those steps, as though that's all that's needed...

Can anyone tell me what I am missing? And thank you in advance!

1
Well, after hunting around for a while, I found a solution: I needed to add a line of code to the "didSelectRowAtIndexPath" method. Specifically, I added this: [self performSegueWithIdentifier:@"newsArticleSegue" sender:nil]; I'd still love to know why I needed to manually add that to my project when none of the tutorials seemed to require it, but I suppose it's academic now. I hope this helps anyone else experiencing this!Nerrolken
It sounds like you did all the right things, but this definitely should work with no code. There's nothing else that you needed to do, so it's hard to tell what went wrong without actually seeing your project.rdelmar
Is your segue automatically generated or is it a custom one? I believe (but not sure though) that only push segues (ctrl-drag-push) work automatically. Maybe I'm mistaken!Alejandro Iván

1 Answers

0
votes

When you create the segue with IB, you can drag from the view controller (which you did) or from the table view cell, which will call the segue if the table view cell is selected.

Select the table view cell before dragging the segue