我有 3 个 UIViews 堆叠在另一个之上
UITableview
planeView
rootView
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 类(didSelectRow:) 中实现的 TableView 委托和 rootView 中的 touchesBegan:,touchesMoved.. 函数也被相应地调用?
即,当我单击 TableCell 时,会调用 (didSelectRow:atIndex) 函数 in--> TableView 和 (touchesBegan and touchesEnd) 方法 in-->rootView。