当子视图可见时,如何禁用selectRowAtIndexPath

时间:2009-12-21 21:48:39

标签: iphone uitableview didselectrowatindexpath

我正在写一个像推特功能一样的“tweetie 2”,但已经遇到了我希望是最后一个绊脚石。

当用户在表格行中滑动时,“控件”会按预期查看动画,但是当选择该行时,会触发 didSelectRowAtIndexPath 。所需的结果是当“控件”视图可见时禁用 didSelectRowAtIndexPath 方法或缺少更好的短语...停止响应者链继续经过“控件”视图。 / p>

在自定义uitablviewcell中使用/调用uitouch委托方法。

2 个答案:

答案 0 :(得分:2)

如何根据需要在allowsSelection设置/取消设置UITableView的值呢?

答案 1 :(得分:1)

一些逻辑应该在这里完成工作。假设您将此属性添加到UITableViewController子类:

NSIndexPath *indexPathForCellInUtilityMode;

当用户触发单元格的实用程序视图时,您的单元格会执行以下操作:

NSIndexPath *cellIndexPath = [parentViewController.tableView indexPathForCell:self];
parentViewController.indexPathForCellInUtilityMode = cellIndexPath;

然后:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


if ([indexPath compare:indexPathForCellInUtilityMode] != NSOrderedSame) {
//Do whatever you're normally doing in this method.
}

因此,您将禁用对受影响单元格的选择,同时仍允许用户与其他可见单元格进行交互。