我有一个TableViewController
与一些项目,然后有一个filterViewController,其中过滤数据在TableViewController
根据值。它是用UISwitch
制成的。无论如何,我想问,如何添加一个SVProgressHUD
的动作,当我从filterViewController返回过滤数组。过滤并在tableView中显示它们需要一些时间。我已经尝试过dispatch_async,它甚至不显示HUD。我有一个IBAction按钮在filterViewController确认值,并将它们发送到TableViewController
。
如果我在filterViewController中添加HUD, 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];
});
});
}
明白了。为TableViewController中的过滤器做BOOL。这比我想象的要容易。