Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform a parent segue from the embedded view controller

I have this:

  • MyTableViewController (inherits from UITableViewController)

    • It has a dynamic tableview with a few cells (foo, bar, qux)

  • MyViewController (inherits from UIViewController)

    • There are some "show" segues from this controller to other view controllers
    • It has a UIContainerView that embeds MyTableViewController

A picture speaks a thousand words:

embedded uitableviewcontroller

When a certain cell is selected, I want to perform a segue of the parent view (MyViewController)

  override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
         if (indexPath.section == 1 && indexPath.row == 1) {
                self.WHAT.performSegueWithIdentifier("someShowSegue1", sender: self)
         }
  }

Is it possible? what should I use in «WHAT»?

like image 676
sports Avatar asked Jun 03 '15 18:06

sports


People also ask

How do I segue between view controllers?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

How do I connect to segue on IOS?

The segue needs to connect from the view controller itself so nothing else triggers it. To create a segue from the controller Control-drag from the View Controller icon to the Exit icon. Give this new segue the identifier unwind to reference it from the code. Time to resume the task of saving a new player.

How do I embed a view controller in navigation controller storyboard?

Storyboard setup In your storyboard, select the initial view controller in your hierarchy. With this view controller selected, choose the menu item Editor -> Embed In -> Navigation Controller .


1 Answers

No need to create a property. Just this

self.parent?.performSegue(withIdentifier: "ID", sender: self)
like image 134
Chris8447 Avatar answered Oct 14 '22 23:10

Chris8447