我有一个小应用程序,它使用多个部分布局来显示初始表视图。其中一个部分显示来自Twitter的最新趋势,另一个部分显示来自Twitter的最新故事。当我在趋势列表中点击某个项目时,我会转到一个新的表视图控制器,该控制器显示有关该趋势的最新推文。在故事部分的根控制器中,我希望能够在包含图像、链接等内容的不同视图控制器中显示更多信息。问题是,当我选择故事部分中的任何内容时,我被推到为趋势部分设置的表视图控制器。我已经为每个segue命名,并且对于我想要过渡到的两个视图都有自定义类,并且我正在这样做以检查调用哪个segue:
有没有关于如何切换视图的建议?
-(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];
}
}
有没有关于如何切换视图的建议?