virusss8
virusss8

Reputation: 235

UITableView inside UITableViewCell - didSelectRowAtIndexPath

I am making an interface which have UITableView with four custom UITableViewCell's. And every other UITableViewCell have also UITableView. This mean I have TableView inside a TableView.

Let me call first tableView - ParentTableView and nested tableView - ChildTableView. So I implemented method didSelectRowAtIndexPath on both tableView's. But when the app is running, only the method of the ChildTableView is being called. I need to know inside the ParentTableView, which cell is being tapped.

How can I transfer that information further from ChildTableView to ParentTableView.

This may be a silly question, but I can not find any reliable solution so far, so please help me.

Thank You in advance, kind Sir

Upvotes: 1

Views: 2418

Answers (2)

iFeli
iFeli

Reputation: 395

Try using collection views. You can do a layout that works like a regular table view and then in the cells that need to have a table, you can make those separate cells with another collection view inside or a table view inside of it.

As mentioned before, it's not easy doing table views inside of cells, and it can be very tricky to get things to work correctly.

This is an old tutorial I wrote which may help and be of guidance. But since then there's been collection views and auto layout, so keep in mind it's very old.

Upvotes: 0

Mundi
Mundi

Reputation: 80273

First, I think nested table views is a bad idea. But I don't know your use case, so it might be an exception.

The table view controller class used inside a cell have its own @protocol definition and set the outer table view as its delegate. In the inner didSelectRowAtIndexPath: it can inform the outer table view about the selected indexPath, its own indexPath and any other information you might want to transmit.

Upvotes: 4

Related Questions