searchDisplayController を使用している場合、ラベル「No Results」を変更するにはどうすればよいですか?
よろしく
searchDisplayController を使用している場合、ラベル「No Results」を変更するにはどうすればよいですか?
よろしく
空の結果セットを持たないことで、ラベルを正常に削除しました。
サーバーからフェッチされているために結果がない場合は、データ ソースを 1 行にリセットし、空白のテーブル ビュー セルを表示します。
さらに、ロジックを使用して「ダミー」セルの選択を拒否します。
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *listItem = [self.filteredListContent objectAtIndex:indexPath.row];
if ([listItem isEqualToString:@""]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
}
willSelect
また、「ダミー」のセル ロジックをデリゲート メソッドに追加する必要があることもわかりました。
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *listItem = [self.filteredListContent objectAtIndex:indexPath.row];
if ([listItem isEqualToString:@""]) {
return nil;
}
return indexPath;
}
直接アクセスできないため、昔ながらの方法で、のサブビューを手動でふるいにかける必要がありますsearchDisplayController.searchResultsTableView
。これが1つの例です:
UITableView *tableView = self.searchDisplayController.searchResultsTableView;
for( UIView *subview in tableView.subviews ) {
if( [subview class] == [UILabel class] ) {
UILabel *lbl = (UILabel*)subview; // sv changed to subview.
lbl.text = @"My custom string";
}
}
searchResultsTableView
ある時点で変更されてアプリが破損する可能性が高い内部動作に依存しているため、これはお勧めしません。Appleでバグ/機能のリクエストを開くことは、ここに行く良い方法です。