2015-05-28 4 views
0

Я пытаюсь вручную вызвать didSelectRowAtIndexPath в UITableview. При этом я получаю следующее исключение:Исключение при ручном вызове didSelectRowAtIndexPath

'Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. 

Вот код вызывает исключение:

-(void)refreshLayerAtIndexPath:(NSUInteger)index { 
    NSIndexPath* indexPath = [[NSIndexPath alloc] initWithIndex:index]; 
    [self tableView:_tableViewLayers didSelectRowAtIndexPath:indexPath]; 
} 

Я не вижу нигде явно установить раздел.

Любые предложения? Благодаря!

+1

Ьгу [само Tableview: _tableViewLayers didSelectRowAtIndexPath: indexPath.row]; и посмотрите, работает ли это –

+1

Вы не должны вызывать 'didSelectRowAtIndexPath:' самостоятельно. Почему вы пытаетесь это сделать? – rmaddy

+1

Кроме того, не называйте свой метод 'refreshLayerAtIndexPath:', поскольку он не принимает указательный путь, а всего лишь индекс. – rmaddy

ответ

2

С UITableView вам также необходимо указать раздел NSIndexPath

NSIndexPath* indexPath = [NSIndexPath indexPathForRow:row inSection:section]; 
2

Используйте это:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; 
Смежные вопросы