2014-07-16 31 views
0

我有一個TableViewController與一些項目,然後有一個filterViewController,其中篩選數據根據值TableViewController。它是用UISwitch製成的。無論如何,我想問一下,如何添加一個SVProgressHUD到動作,當我從filterViewController返回過濾數組。它需要幾秒鐘過濾並在tableView中顯示它們。我已經嘗試過dispatch_async,甚至不顯示HUD。我有一個在filterViewController中的按鈕的IBAction來確認值並將它們發送到TableViewControllerSVProgressHUD如何顯示在下一個ViewController

如果我將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

明白了。對於TableViewController中的篩選器,只做BOOL。這比我想象的要容易。

相關問題