1

This is what my view controller looks like:

enter image description here

When I run the app, only the little info icon will respond to taps. Taps anywhere else in the cell are ignored. How do I make the whole cell clickable?

I don't even want the info icon to be there, but it's the only way I can get to the detail view, currently... If I change the Accessory setting of the cell to "None" to get rid of the info/"Detail Disclosure" icon, then the cell won't respond to taps at all.

EDIT:
Thanks for your responses so far. In response to some of your questions, I do have a cellForRowAtIndexPath method, and it is getting called. However, I am also using a seque to connect my cell to the next controller, but the prepareForSeque:sender method only gets called if/when I tap on the info icon, not when I tap on the cell...

I'm currently trying to figure out why the prepareForSeque method isn't getting called when I tap on the cell (like it has when I've used table views in the past)...

I've looked at prepareForSeque doesn't fire (as suggested by iMani), but I DO have an identifier for my cell.

I also looked at PrepareForSeque not called/fired, which talks about manually calling performSegueWithIdentifier:sender. However, I've never had to manually call that in the past when I've used table views, and my cells in the past have still triggered the prepareForSeque method...

Community
  • 1
  • 1
Troy
  • 21,172
  • 20
  • 74
  • 103
  • 1
    did you implemented `didSelectRowAtIndexPath` delegate method of `UITableView` – Akhilrajtr Feb 05 '14 at 05:44
  • I've implemented the method (actually, *Apple* implemented the method - I'm just using the default MasterViewController that Apple creates when you create a new "Master-Detail Application" project). But I'm also using a segue to connect the cell to my next controller. However, the prepareForSeque method isn't getting called when I click the cell, it only gets called when I click the info icon... – Troy Feb 05 '14 at 06:07
  • Check whether you are connecting your cell to the next controller or you are connecting the icon in storyboard/Xib? If you are connecting the icon, then try to connect the cell to the next view controller in your storyboard/Xib. Also check for the cell identifier in your storyboard/Xib and match it to the one that you have given in cellForRowAtIndexPath. See if it helps. – Sudershan shastri Feb 05 '14 at 06:41
  • The issue was that I had created the wrong type of seque. See my answer below and the solution here: http://stackoverflow.com/questions/21582049/xcode-is-auto-adding-an-info-icon-accessory-button-to-my-table-cells. – Troy Feb 05 '14 at 16:30

4 Answers4

0

simply implement the table view delegate method, and make sure you connected your table view with the delegate:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

you can find some more delegate method here:

Apple Docs

Xu Yin
  • 3,932
  • 1
  • 26
  • 46
  • When I've used table views in the past (not that I have a ton of experience - I am pretty new), I control-click on the cell and drag to my next controller to create a segue from the cell to the view. When I tap on the cell, the prepareForSegue:sender method gets called. In this case, the prepareForSegue method only gets called when I click on the info icon... I'm not sure what is causing this different behavior this time. – Troy Feb 05 '14 at 05:53
0

You can use the UITableView's delegate method , which will be respond to the whole cel when its clicked

implement the below delegate method ,before doing it make your tableview setdelegate to self and setdatasource to self and implement UITableViewDelegate,UITableViewDataSource in your interface class(.h)

-(void) tableView:(UITableView *)_tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Rajjjjjj
  • 424
  • 3
  • 16
0

Check this in tableview xib..? and Don't Accessory setting of the cell to "None"

enter image description here

Finally implement didSelectRowAtIndexPath: delegate method to handle selection.

Mani
  • 17,549
  • 13
  • 79
  • 100
  • The thing I'm not understanding is why isn't the prepareForSeque:sender method getting called? That's how it has worked when I've used table views in the past... but now that method only gets called if/when I tap on the info icon. – Troy Feb 05 '14 at 06:03
  • see this link http://stackoverflow.com/questions/8876408/prepareforseque-doesnt-fire and this http://stackoverflow.com/questions/16778452/prepareforseque-not-called-fired – Mani Feb 05 '14 at 06:04
0

The issue was that I had created the wrong type of seque. The fix for this question also fixes the behavior I was seeing here.

Community
  • 1
  • 1
Troy
  • 21,172
  • 20
  • 74
  • 103