David Seek
David Seek

Reputation: 17122

Swift / Perform custom segue from tableView

I have a tableView with segue on tap. It works perfect. But I want to customize the transition.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
    if indexPath.row == 0
    {
        print("Home")
        self.performSegueWithIdentifier("ShowHomeSegue", sender: self)
    }
    else if indexPath.row == 1
    {
        print("Specials")
        self.performSegueWithIdentifier("ShowSpecialsSegue", sender: self)
    }
    else if indexPath.row == 2
    {
        print("Info")
        self.performSegueWithIdentifier("ShowInfoSegue", sender: self)
    }
    else if indexPath.row == 3
    {
        print("Kontakt")
        self.performSegueWithIdentifier("ShowKontaktSegue", sender: self)
    }
    else if indexPath.row == 4
    {
        print("Offnungszeiten")
        self.performSegueWithIdentifier("ShowOffnungszeitenSegue", sender: self)
    }
    else if indexPath.row == 5
    {
        print("Gallerie")
        self.performSegueWithIdentifier("ShowGallerieSegue", sender: self)
    }
    else if indexPath.row == 6
    {
        print("Location")
        self.performSegueWithIdentifier("ShowLocationSegue", sender: self)
    }

}

I have a "class MenuTransitionManager", that I use within the mainViewController, when I press the menuButton to open the menu.

The View becomes a snapshot, moves to the right and the menu moves from the left to the middle.

"class MenuTransitionManager" is called within the performSegueWithIdentifier at the mainViewController.

How can I call my custom transition from "class MenuTransitionManager" withing my tableView?

Upvotes: 0

Views: 86

Answers (1)

farzadshbfn
farzadshbfn

Reputation: 2748

You can implement a CustomSegue class inherited from UIStoryBoardSegue and in storyboard click on the segue and set it's class. Now when you call performSegueWithIdentifier: it will call your custom segue.

Upvotes: 1

Related Questions