Có khả năng đặt lại UISearchbar bằng searchDisplayController theo chương trình đang hoạt động và đã chứa văn bản không?Đặt lại UISearchbar theo lập trình
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.searchDisplayController.searchResultsTableView) {
searchDisplayController.searchResultsTableView.hidden = YES;
searchBar.showsCancelButton = NO;
[searchBar resignFirstResponder];
}
}
Giải pháp này đang hoạt động nhưng vẫn có văn bản trong thanh tìm kiếm. Nếu tôi thêm các dòng mã đó:
searchBar.text = @"";
Luôn có chế độ xem trong suốt màu đen.
Bất kỳ giải pháp nào?
thử searchBar.text = nil; –