在扩展单元中启用和禁用UI工具栏

我有一个单元格(videoCell),当未选中的高度是100px,选中时展开为144px。 在扩展的44​​个像素中,我通过故事板放置了一个工具栏(detailToolbar)。

现在,这是我的问题。 如果为工具栏启用了用户交互function,则条形button可以正常工作,并且只需closures单元格,我就可以轻触任何单元格的原始100像素。 但是,当我试图扩大一个单元格时出现问题。 如果我点击未选定单元格的底部44px,则不会触发任何事件,但只有在select了顶部的56个像素时才会响应。 我假设单元格后面的detailToolbar阻止了它的工作。

这是我的一些代码。 我正在使用Simon Lee的教程来扩展单元格。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { // If our cell is selected, return double height if([self cellIsSelected:indexPath]) { return 144.0; } // Cell isn't selected so return single height return 100.0; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Deselect [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; self.tableView.clipsToBounds = YES; // Store cell 'selected' state keyed on indexPath NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected]; [selectedIndexes setObject:selectedIndex forKey:indexPath]; // This is where magic happens... [self.tableView beginUpdates]; [self.tableView endUpdates]; } 

我自己回答了。 我做了select行方法中的以下内容:

 for(NewsCell *cell in [self.tableView visibleCells]) { BOOL cellIsSelected = isSelected; [cell.detailToolbar setUserInteractionEnabled:cellIsSelected]; } 

它完美无缺地工作!