发生segue后如何刷新tableview?

时间:2013-06-06 01:14:32

标签: objective-c uitableview view uistoryboardsegue

我在视图控制器内部放置了一个触发segue的按钮。在我的数据(在这种情况下,pickerview数据)通过segue从我的视图控制器传递到tableview之后,我想刷新tableview(位于segue的目标控制器中)。我怎样才能做到这一点?请参阅下面的代码。

- (IBAction)buttonpressed:(UIButton *)sender {

        NSLog(@"Button Pushed!");

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"pickerGo"])
    {
        // Get reference to the destination view controller
        ViewController *strainTableView = [(UINavigationController *)[segue destinationViewController] topViewController];

        NSPredicate *ailmentPredicate = [NSPredicate predicateWithFormat:@"Ailment contains[cd] %@", [pickerView selectedRowInComponent:0]];

        NSPredicate *actionPredicate = [NSPredicate predicateWithFormat:@"Action contains[cd] %@", [pickerView selectedRowInComponent:1]];

        NSPredicate *ingestPredicate = [NSPredicate predicateWithFormat:@"Ingestion contains[cd] %@", [pickerView selectedRowInComponent:2]];


        NSCompoundPredicate *resultPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects: ailmentPredicate,actionPredicate,ingestPredicate, nil]];

        pickerResults = [Strains filteredArrayUsingPredicate:resultPredicate];


        // Pass any objects to the view controller here, like...
        [strainTableView setSearchResults: pickerResults];


    }
}

0 个答案:

没有答案