に問題があります。これは、検索されたユーザーを表示するために使用される " " ファイルUISearchController
で宣言されています。すべてはタイトルにあります。「 」ファイルFindUsersTableViewController.h
のコードの重要な部分について詳しく説明します。FindUsersTableViewController.m
- (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 は何も表示しません...誰もそれを修正する方法を知っていますか?