0

TableViewController有一些项目,然后有一个 filterViewController,TableViewController根据值过滤数据。它是用UISwitch. 无论如何,我想问一下SVProgressHUD,当我从带有过滤数组的 filterViewController 返回时,如何将 a 添加到操作中。在 tableView 中过滤和显示它们需要几秒钟。我已经尝试过 dispatch_async,它甚至不显示 HUD。我在 filterViewController 中有一个 IBAction 按钮,用于确认值并将它们发送到TableViewController.

如果我将 HUD 添加到 filterViewController 中的操作,HUD 不会显示在 TableViewController 中。

过滤器视图控制器.m

-(IBAction)Done:(id)sender{

    [self willMoveToParentViewController:nil];

    [self.navigationController popViewControllerAnimated:YES];


}

表视图控制器.m

- (void)filterController:(filterViewController *)controller didEditConfig:(NSMutableDictionary *)config
{
    [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeGradient];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        // time-consuming task

        self.konfigg = config;


        NSSet *filter = [config keysOfEntriesPassingTest:
                         ^BOOL (id key, NSNumber *value, BOOL *stop) {
                             return [value boolValue];

                         }];

        NSLog(@"filtered keys: %@ (%lu of %lu)", filter, (unsigned long)filter.count, (unsigned long)config.count);

        PFQuery *query = [PFQuery queryWithClassName:@"Class"];
        [query addDescendingOrder:@"createdAt"];
        [query whereKey:@"eventDay" containedIn:[filter allObjects]];

        [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

            if (!error) {
                self.itemss = [objects mutableCopy];
                [self.MainTable reloadData];

                NSLog(@"Got filtered results %@ (%lu)", objects, (unsigned long)objects.count);
            }}
         ];
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
    });

}
4

1 回答 1

0

知道了。为 TableViewController 中的过滤器制作了 BOOL。这比我想象的要容易。

于 2014-07-16T12:25:00.783 回答