Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

ios - How to make a push segue when a UITableViewCell is selected

I have a list of effects in a table view. I have created a top right bar button which does a push segue to another view controller which helps create a new effect. Now I want to add push segues to the table view cells so that the effects values maybe loaded on the add effects view controller and I can save the edited values.

The question is can I create a push segue programmatically? If not can I pass the effect through a prepareforsegue? If I try to use a prepareforsegue, I run into a problem where control dragging from the UITableView does not let me create a push segue to the add effects view controller.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

control drag From View Controller to View Controller

From View Controller to View Controlle!

You will need to give an identifier to your segue:

enter image description here

Perform the segue:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"yourSegue" sender:self];
}

Now here is the thing, this will just perform the segue, if you ever needed to pass some data to that view controller. Then you have to implement the following segue delegate:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"yourSegue"])
    {
        //if you need to pass data to the next controller do it here
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...