How can I change strings of “Cancel” button, “No Results” label in UISearchBar of UISearchDisplayController?

前端 未结 4 1193
借酒劲吻你
借酒劲吻你 2020-12-02 18:05

How can I change strings of \"Cancel\" button, \"No Results\" label in UISearchBar of UISearchDisplayController?

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 18:25

    Thank you ChangUZ for finding a way. Now, for improvement, a timer is not needed to alter the "No Results" label.

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
    {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            for (UIView *v in controller.searchResultsTableView.subviews) {
                if ([v isKindOfClass:[UILabel self]]) {
                    ((UILabel *)v).text = @"_____";
                    break;
                }
            }
        });
        return YES;
    }
    

提交回复
热议问题