Multiple Transitions from a Table View Controller

I have a small application that uses several section sections for the initial presentation of a table. One section shows the latest trends from Twitter, and another section shows the latest stories from Twitter. When I click on an item in the trend list, I go to the new table view controller, which displays the latest tweets about this trend. Inside the root controller for the story section, I looked to be able to display more information in another view controller that contains images, links, etc. The problem is that when I select something in the history section, they push me into the table view controller that is configured for the trend section. I named each segue and created custom classes for both the views I want to go to,and I do this to check which call is being called:

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if([[segue identifier] isEqualToString:@"viewTrendsSearch"]) {

        //get the controller that we are going to segue to
        SearchTrendResultsViewController *strvc = [segue destinationViewController];

        //get the path of the row that we want from the table view
        NSIndexPath *path = [self.tableView indexPathForSelectedRow];

        //here we get the trend object from the array we set up earlier to hold all trends
        Trends *results = [currentTrends objectAtIndex:[path row]];

        //pass the object that was selected in the table view to the destination view
        [strvc setQuery: results];
    }

    if([[segue identifier] isEqualToString:@"storyfullDetails"]) {

        StoriesViewController *svc = [segue destinationViewController];

        NSIndexPath *path = [self.tableView indexPathForSelectedRow];

        Stories *results = [currentStories objectAtIndex:[path row]];

        [svc setStory:results];
    }
}

, ?

+5
1

, , segues .

IB segue () . , , , - segue, , , - prepareForSegue:sender:, . , ( ) ( , ).

A segue IB . , . , , , , ( performSegueWithIdentifier:, ).

, :

  • - . tableView:cellForRowAtIndexPath:, dequeueReusableCellWithIdentifier:, , .

  • . tableView:didSelectRowAtIndexPath: performSegueWithIdentifier: , .

prepareForSegue:sender: .

+16

All Articles