segue when clicking on collection view cell embedded in table view cell

uitableviewcell segue programmatically
segue from uitableviewcell to viewcontroller swift 4
table view cell click action
uicollectionview edit mode
table view cell to view controller
table view cells not showing
tableview didselectrowatindexpath segue swift
passing data from tableview to viewcontroller swift 4

I have the following app logic

TableView Controller => Table View Cell => CollectionView embeded in each table view cell

I want when I click on a collection view cell to segue the table view controller to another controller.

Does anyone know how to do this?

Here's my code:

In tableViewControler

    let cell = tableView.dequeueReusableCell(withIdentifier: "book", for: indexPath) as! BookTableViewCell
            let books = (indexPath.row == 2) ? trendingbooks : newbooks
            if (cell.collectionView === nil) {
                cell.addCollectionView();
            }

    performSegue(withIdentifier: "bookDetail", sender: indexPath)
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        let dc = segue.destination as! DetailViewController
        dc.data = self.tableRowData;
    }


In BookTableViewCell

    func addCollectionView () {
        let flowLayout = UICollectionViewFlowLayout()
        flowLayout.scrollDirection = .horizontal

        let cellWidth = UIScreen.main.bounds.width / 3
        let cellHeight = UIScreen.main.bounds.height / 3
        flowLayout.itemSize = CGSize(width: 100, height: self.frame.height)

        //You can also provide estimated Height and Width
        flowLayout.estimatedItemSize = CGSize(width: 100, height: self.frame.height)

        //For Setting the Spacing between cells
        flowLayout.minimumInteritemSpacing = 20
        flowLayout.minimumLineSpacing = 20

        let cellReuseIdentifier = "collectionCell"
        self.collectionView = UICollectionView(frame: CGRect(x: 0,
                                                             y: 0,
                                                             width: self.frame.width,
                                                             height: self.frame.height),
                                               collectionViewLayout: flowLayout)
        self.collectionView.showsHorizontalScrollIndicator = false
        self.collectionView.translatesAutoresizingMaskIntoConstraints = false
        self.collectionView.backgroundColor = .clear
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.collectionView.register(BookCollectionViewCell.self, forCellWithReuseIdentifier: cellReuseIdentifier)

        self.addSubview(collectionView)
    }

I believe that the function you are looking for is tableView(_:didSelectRowAt:)

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    self.performSegueWithIdentifier("bookDetail", sender: indexPath)
}

ios, I have the following app logic. TableView Controller => Table View Cell => CollectionView embeded in each table view cell. I want when I click on a collection  Stack Overflow Public questions I wish to pass data through segue from a collectionViewCell embedded in a Use of undeclared type 'cell' - Collection View. 2.

I think you can use segue like this way in your case:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == segueIdentifier,
       let destination = segue.destination as? DetailViewController,
       let selectedIndexPath = tableView.indexPathForSelectedRow,
       let selectedCell = tableView.cellForRow(at: indexPath) as? YourCell 
    {
        let collectionView = selectedCell.collectionView
        // Then do your stuff here
    }
}

ashfurrow/Collection-View-in-a-Table-View-Cell, How would I perform segues from the collectionView cells? #6 -i-segue-from-​uicollectionviews-cells-embedded-inside-uitableviewcell-s I had a button in the cell and when hitting the cell the button was getting clicked, and  The collection view delegate is hooked up to the table view cell and the table view delegate is hooked up to the main view controller. I want to segue on a cell tap to a new view controller using the navigation controller's push method and pass data from the collection view cell to the new view controller.

The embedded collection view's delegate (the BookTableViewCell) will be the first to hear about the selection. The question is how should that tableview cell convey the selection to the VC that contains it. One answer is to define a delegate on the BookTableViewCell that passes info about the selection from the embedded collection view to the containing VC.

So when configuring the BookTableViewCell, set its delegate to the VC that contains it and have the VC implement this method to perform the segue.

protocol BookTableViewCell Delegate {
    func didSelectInEmbeddedCollection(cell: BookTableViewCell, at: IndexPath)
}

Have the cell's implementation of the embedded collection view's didSelectItem method, call this didSelectInEmbeddedCollection.

Segue from UITableViewCell Taps in Swift, and then go to the top menu and click on Editor → Embed In → Navigation Controller. Ctrl+Drag from the UITableViewCell to our new view controller. This means that when you tap on the cell, it will cause this segue to happen. Now, click on “BlogViewController.swift” and let's get this one set up. Ctrl+Drag from the UITableViewCell to our new view controller. You will then be presented with this dialog about what segue to create: For this, we are going to select the “show” segue in the “Selection Segue” section. This means that when you tap on the cell, it will cause this segue to happen.

[PDF] Lecture 7, Collection views support customizable layouts that can be used You can customize both the look of the table view and its cells from Interface. Builder. Click on the table view (not the table view controller) to see its Table View Segues You might also want to embed your Table View Controller in a Navigation Controller. The next step is we need to figure out which table view contains the cell's collection view. This is handled for us by the tag property. Just like how we set a cell's background colour based on its collection view's tag, we can use the same logic to identify the object that was selected.

perform segue collection view inside a tableview – Onooks, UICollectionview that embedded into a UITableView. now I want to perform a segue to a new ViewController when user has clicked on a cell. Table View Segue to Multiple View Controllers Using Swift 3 and Xcode 8 This is different from the video for the collection view, but this one is easier!

Collection Views in iOS 12: Learn how to include Collection Views , The Collection View was embedded in a Navigation Controller and the prototype cell was connected to a detail view with a Show Segue. The difference with Table Views is that the only method provided by Collection Views to get the path​  In this video, we will learn how to use segues in cell selection also known as did select row in UITableView. We will cover following points in this video 1) Detect cell click or cell action in

Comments
  • When the user clicks on a collection view cell in tableview cell how do I get them to segue all the way to the table view controller?
  • If I'm understanding your question correctly, you need to make sure that the destination is set correctly. As someone pointed out in another answer, you should make sure you are casting the destination view controller correctly e.g.: let destination = segue.destination as? DetailViewController
  • When I click on the collection view cell in the table view cell inside the table view, the didSelectRowAt tableViewController function does not get triggered, so I can't call performSegueIdentifier
  • You might need a callback from your collection view cell selection which contains information of the tableview cell that the collection view is embedded in. And then perform your segue.
  • Where do I put didSelectInEmbeddedCollection?
  • Define the protocol and a delegate property on the custom BookTableViewCell. When configuring the cell (after dequeue) set the delegate to self (the containing vc). The containing vc then must implement didSelectInEmbeddedCollection. It can trigger the segue from there
  • The key idea is that the collection view is two levels down from the VC, so you sort of need two levels of delegation. The first level is provided by the collection view itself. The second must be provided by the custom cell. Complex, but its a complex arrangement of views that you're starting with
  • I get an error when I try to set a delegate on the tableviewcell, do you happen to know why @danh?
  • I'd have to see the code and the error. You'll get one if the VC doesn't declare itself as conforming to the protocol defined by the cell