vzm
vzm

Reputation: 2450

How to perform segue from UITableView to UIView?

I have my TableViewController setup as different Static cells, with 18 different buttons all setup in storyboards. Each button should segue to my View but bringing down some set of information with it. So far,I have given each button a different tag & I have it so that for each box, it assigns a value to a variable, I have tested this to be working with my console:

- (IBAction)startClicked:(id)sender {

    if ([sender tag] == 0) {
        _selectionName = @"Box A";

    }
    else if ([sender tag] == 1){
        _selectionName = @"Box B";

    }
    else if ([sender tag] == 2) {
        _selectionName = @"Box C";

    }
}

But now, my question is: How to I add a segue to from my TableViewController to my view AND bring _selectionName's value as well?

Please be as detailed as possible, sample code would be great. Cheers

Upvotes: 1

Views: 197

Answers (1)

Duncan C
Duncan C

Reputation: 131398

You don't segue from a UITableView to a UIView.

Segues are from one view CONTROLLER to another.

If you're using static cells, you should be able to control-drag from the buttons to the destination storyboard scene(s). Name each segue with a unique name, and then implement a prepareForSegue method. In that method, check the segue name, and use it to set up the desired properties in your destination view controller.

Alternately, you could use an IBAction like you are doing, and then in that IBAction set up your _selectionName as you have it in your post, then, use the method performSegueWithIdentifier:sender: to invoke your segue. Again, use the prepareForSegue method to pass your _selectionName value to a property of your destination view controller.

Upvotes: 1

Related Questions