2015-07-09 6 views
0

Я построил простой стол с дополнительным видом для каждой строки. Я добавил uisearchcontroller. Каждый раз, когда я ищу объект, а затем выбираю вид аксессуара для этого объекта, изображение вспомогательного представления не обновляется.ViewView AccessView ViewView View не обновляется

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { 
UIButton *button = (UIButton *)cell.accessoryView; 
UIImage *Image; 
Image = [UIImage imageNamed:@"unchecked.png"]; 
[button setBackgroundImage:Image forState:UIControlStateNormal]; } 

После того, как я отменил поиск, для строк, которые я искал, отображаются галочки (вид аксессуаров).

+0

Это ваш весь столПросмотр: аксессуарыButtonTappedForRowWithIndexPath :? Где определена переменная ячейки? –

+0

'if (self.searchDisplayController.searchBar.text.length> 0) { stringxyz = [searchResults objectAtIndex: indexPath.row]; } else { stringxyz = [self.someArray objectAtIndex: indexPath.row]; } NSIndexPath * indexValue = [NSIndexPath indexPathForRow: [self.someArray indexOfObject: stringxyz] inSection: 0]; \t UITableViewCell * cell = [self.tableView cellForRowAtIndexPath: indexValue]; ' – CarlosSantos

+0

Решение найдено. http://stackoverflow.com/questions/11352403/reloading-searchresultstableview – CarlosSantos

ответ

0

Вы должны использовать ячейку resultTableView из UISearchController, попробуйте следующее:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { 
    if(tableView == self.searchDisplayController.searchResultsTableView) 
     cell=[self.searchDisplayController.searchResultsTableView cellForRowAtIndexPath:indexPath]; 
    else 
     cell=[self.tableView cellForRowAtIndexPath:indexPath]; 
    UIButton *button = (UIButton *)cell.accessoryView; 
    UIImage *Image; 
    Image = [UIImage imageNamed:@"unchecked.png"]; 
    [button setBackgroundImage:Image forState:UIControlStateNormal]; } 
+0

Не работает для меня :(Аксессуар Посмотреть все еще без изменений в searchResultsTableView – CarlosSantos

+0

может быть, мне нужно что-то, чтобы обновить результаты поиска? – CarlosSantos

0

Это работает для меня! Спасибо пользователю207616

if (self.searchDisplayController.active) { 
self.searchDisplayController.searchBar.text = self.searchDisplayController.searchBar.text; } 
Смежные вопросы