0

我在触发 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];


    }
}
4

0 回答 0