0
我有一個UISearchBar和UISearchDisplayController正確實施,以過濾UITableView中的單元格。爲什麼UISearchDisplayController有時會工作,有時候不行?
有時它工作正常,並根據輸入的搜索詞過濾單元格。 但有時 - 無需更改一行代碼 - 它不會過濾並顯示所有單元格。
在tableView代表中,我注意到下面的IF
語句是FALSE
,因此在searchResultsTableView
中顯示所有聯繫人作爲搜索結果。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
return [_searchResultContacts count];
}
else
{
return [_allContacts count];
}
}
這是爲什麼?
(不回答,我會後下面的答案!)