2

我对 EasyTableView 有一个简单的问题(https://github.com/alekseyn/EasyTableView)

我有许多可以正常工作的水平滚动表。

我能够选择一个单元格并执行一个转场,但是,一旦新的视图控制器被解除,我将不再能够选择该单元格并执行相同的操作,直到我在同一个表中选择了另一个单元格。

我的问题是:如何以编程方式取消选择以前选择的单元格以重新启用此特定操作。

提前致谢!

4

1 回答 1

3

selectedIndexPath 是有意持久的,以防用户将选定的 tableview 单元格滚动到屏幕外然后再次返回。如果您不想要这种持久性,请在委托方法之后添加如下所示的行(在 EasyTableView.m 中):

- (void)setSelectedIndexPath:(NSIndexPath *)indexPath {

    if (![_selectedIndexPath isEqual:indexPath]) {
        NSIndexPath *oldIndexPath = [_selectedIndexPath copy];

        _selectedIndexPath = indexPath;

        UITableViewCell *deselectedCell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:oldIndexPath];
        UITableViewCell *selectedCell   = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:_selectedIndexPath];

    if ([delegate respondsToSelector:@selector(easyTableView:selectedView:atIndexPath:deselectedView:)]) {
        UIView *selectedView = [selectedCell viewWithTag:CELL_CONTENT_TAG];
        UIView *deselectedView = [deselectedCell viewWithTag:CELL_CONTENT_TAG];

        [delegate easyTableView:self
                   selectedView:selectedView
                    atIndexPath:_selectedIndexPath
                 deselectedView:deselectedView];

        // Add this line here!
        _selectedIndexPath = nil;
        }
    }
}
于 2013-01-08T16:53:36.597 回答