我正在使用TableViewController
包含一些项目,然后使用filterViewController,根据值在TableViewController
中过滤数据。它是使用UISwitch
制作的。无论如何,我想问一下,当我从带有过滤数组的filterViewController返回时,如何向动作添加SVProgressHUD
。在tableView中过滤并显示它们需要几秒钟。我已经尝试过dispatch_async,它甚至没有显示HUD。我在filterViewController中有一个IBAction按钮来确认值并将它们发送到TableViewController
。
如果我将HUD添加到filterViewController中的操作,则HUD不会显示在TableViewController中。
filterViewController.m
-(IBAction)Done:(id)sender{
[self willMoveToParentViewController:nil];
[self.navigationController popViewControllerAnimated:YES];
}
TableViewController.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];
});
});
}
答案 0 :(得分:0)
知道了。在TableViewController中为过滤器制作了BOOL。这比我想象的容易。