Ios UISearchController未使用PFQueryTableView更新

Ios UISearchController未使用PFQueryTableView更新,ios,objective-c,parse-platform,uisearchdisplaycontroller,uisearchresultscontroller,Ios,Objective C,Parse Platform,Uisearchdisplaycontroller,Uisearchresultscontroller,正在尝试使用Parse.com在我的应用程序上实现UISearchController以进行查询。在线上有一些示例,但旧的“UISearchDisplayController”现在已被弃用 不管怎么说,根据我的NSLog搜索和查询,我似乎一切正常,但tableview根本没有得到更新,我也不知道为什么 以下是我所做的: @interface LocalSalesViewController () <UISearchResultsUpdating, UISearchControllerDel

正在尝试使用Parse.com在我的应用程序上实现UISearchController以进行查询。在线上有一些示例,但旧的“UISearchDisplayController”现在已被弃用

不管怎么说,根据我的NSLog搜索和查询,我似乎一切正常,但tableview根本没有得到更新,我也不知道为什么

以下是我所做的:

@interface LocalSalesViewController () <UISearchResultsUpdating, UISearchControllerDelegate>


@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) NSMutableArray *searchResults; // Filtered search results

@end

@implementation LocalSalesViewController
- (id)initWithCoder:(NSCoder *)aCoder {
    self = [super initWithCoder:aCoder];
    if (self) {
        self.parseClassName = @"Sales";
        self.pullToRefreshEnabled = YES;
        self.paginationEnabled = YES;
        self.objectsPerPage = 25;
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];

    self.searchResults = [NSMutableArray array];
    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
    self.searchController.searchResultsUpdater = self;
    self.searchController.delegate = self;
    self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
    self.tableView.tableHeaderView = self.searchController.searchBar;
    self.definesPresentationContext = YES;

}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
    static NSString *CellIdentifier = @"Cell";

    LocalSalesTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    if (cell == nil)
    {
       cell = [[LocalSalesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }

        object = (tableView == self.tableView) ? self.objects[indexPath.row] : self.searchResults[indexPath.row];

        cell.saleTitle.text = [object objectForKey:@"name"];

    return cell;


}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.tableView) {


        return self.objects.count;

    } else {

        return self.searchResults.count;

    }
}


#pragma mark - UISearchResultsUpdating
-(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
    NSString *searchString = [self.searchController.searchBar text];
    [self updateFilteredContentForSaleName:searchString];
     [((UITableViewController *)self.searchController.searchResultsController).tableView reloadData];
}
#pragma mark - Content Filtering
- (void)updateFilteredContentForSaleName:(NSString *)saleName {
    [self.searchResults removeAllObjects];

    for (PFObject *sale in self.objects)
    {
        NSString *saleTitle = [sale objectForKey:@"name"];
        if ([[saleTitle lowercaseString] hasPrefix:[saleName lowercaseString]])
        {
            [self.searchResults addObject:sale];
        }
    }
    NSLog(@"%@", self.searchResults);

}
self.searchResults日志似乎正在做它应该做的一切,通过过滤掉那些单元格并添加到数组中,但是根本没有更新任何单元格。

AFAIK,调用initWithSearchResultsController:nil意味着self将是用于显示结果的视图控制器

因此UITableViewController*self.searchController.searchResultsController.tableView是self.tableView

因此,如果tableView==self,那么tableView将始终为true