iosswiftsegue

Swift. How to create Segue from custom CollectionViewCell to .xib File (ViewController), by programmatically maybe?


How to create Segue from custom CollectionViewCell to .xib File (ViewController, is a Player), by programmatically maybe?

I do have main ViewController on Storyboard but almost all components i made by code. And also have xib file - PlayerViewController.

In the main ViewController I have CollectionView with custom cell.

And on tap on any cell I need to push Data (Video object) to PlayerViewController.

If by Segue, how can I create Segue identifier by Code? Or on storyboard but without “drag-and-connect”


Solution

  • You do not need segue you can pass data programmatically like this.

    Let suppose your XIB and controller name is same.

    let controller =  YourViewController()
    controller.data = yourdatta
    self.navigationController.push(controller)