Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table View Cell Segues not Working

I'm trying to do something very simple: set up a segue so that when you click on a cell in a table it will take you to another View Controller. The problem, I believe, originates from the fact that the TableView these cells are in is embedded in a regular ViewController (as opposed to a TableViewController), and is one of two subviews in this ViewController.

As far as I can tell, I've set everything up correctly: I embedded the ViewController with the two subviews in a Navigation Contoller, set it to be the dataSource and delegate for the TableView, and created a push segue from a TableViewCell to my second View Controller in the storyboard. However, when the app is run and a user clicks a row in the table, it merely selects the row and the segue doesn't fire at all (I've debugged it and the prepareForSegue function isn't even being called).

Is there something I'm missing here? Or is this for some reason not possible if the TableView is not the only view in its view controller?

like image 415
generaltsow Avatar asked Apr 21 '12 21:04

generaltsow


2 Answers

I find that if I had recently wired the segue from the cell's accessory view, and later delete the segue and try to wire a new segue to the cell directly it does not work (using Xcode 4.6.2) -- Xcode keeps connecting the segue to the accessory view (even if there isn't one)! The way I fixed it is by selecting the cell in IB and using the connection inspector to (1) delete the original "accessory action" segue and (2) directly wire the "selection" segue by dragging from the filled circle in the image below to the appropriate destination view controller.

enter image description here

like image 82
wcochran Avatar answered Nov 16 '22 01:11

wcochran


This may or may not help you, but I ran into this issue because I had defined two different cell types, and had provided didSelectRowAtIndexPath implementation. I had to add [self performSegueWithIdentifier:@"Whatever" sender:self] as part of didSelectRowAtIndexPath and the issue got resolved.

If you are able to at least detect row selections, you may be able to take advantage of this method.

like image 20
LNI Avatar answered Nov 16 '22 01:11

LNI