2015-02-11 115 views
0

我有一個UISearchController的問題,它在我的「FindUsersTableViewController.h」文件中聲明用於顯示搜索到的用戶。 所以,一切都在標題中,我給你的「FindUsersTableViewController.m」文件的代碼重要部分的詳細信息:UISearchController不顯示任何東西

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil]; 
    self.searchController.dimsBackgroundDuringPresentation = NO; 
    self.searchController.searchResultsUpdater = self; 
    self.searchController.delegate = self; 
    self.searchController.searchBar.frame = CGRectMake(0, 0, 320, 44); 
    self.tableView.tableHeaderView = self.searchController.searchBar; 
    self.searchController.searchBar.tintColor = [UIColor blackColor]; 
    self.definesPresentationContext = YES; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

    return self.searchResults.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *userCellId = @"userCell"; 

    UserCell *userCell = [tableView dequeueReusableCellWithIdentifier:userCellId forIndexPath:indexPath]; 
    // "self.searchedUser" is a property declared as PFUser in the .h file 
    PFUser *tempSrchUser = self.searchedUser; 
    // "self.searchResults" is a property declared as NSMutableArray in the .h file too, it contains the searched users 
    PFObject *searchedUser = [self.searchResults objectAtIndex:indexPath.row]; 

    NSString *tempUsername = [searchedUser objectForKey:tempSrchUser.username]; 

    userCell.usernameLbl.text = tempUsername; 

    NSLog(@"retrieved appropriates usernames: %@", userCell.usernameLbl.text); 

    return userCell; 
} 

的UISearchController不顯示任何東西...有誰知道如何解決這個問題?

回答