【发布时间】:2011-12-28 23:43:05
【问题描述】:
我有 3 个 UIViews 堆叠在另一个之上
UITableview
平面视图
根视图
TableView 位于顶部,rootView 位于底部。 (rootView 不可见,因为 TableView 在它上面)
我在rootView中实现了以下代码
/*code in rootView*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
期望这些函数会在最顶层的视图即 TableView 被触摸或移动时被调用,但相反没有调用任何函数。
我还尝试将以下代码放入 TableView 中,以便调用 rootView 方法
/*code in TableView so that the rootView methods are called(TableView is the subview of rootView)*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.superview touchesBegan:touches withEvent:event];
}
正如预期的那样,但问题是 TableView 代表喜欢
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
没有被调用。
有什么方法可以确保TableView类中实现的TableView委托(didSelectRow:)和rootView中的touchesBegan:,touchesMoved..函数也被相应调用?
即当我单击 TableCell 时,会调用 (didSelectRow:atIndex) 函数 in--> TableView 和 (touchesBegan and touchesEnd) 方法 in-->rootView。
【问题讨论】:
标签: uitableview uiview uievent