我有3个UIViews堆叠在另一个上堆叠UITableViews没有通过触摸事件视图下方
的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 ..函数也被相应调用?
ie当我点击一个TableCell时,两个(didSelectRow:atIndex)函数在 - > TableView和(touchesBegan和touchesEnd)方法中 - > rootView被调用。
伟大resolution.Thanks的帮助 – prajul
但仍在某个时间点touchesEnded:不叫。我已经做了一些调整touchesEnded:消息的视图位置,但由于消息不是总是通过视图调整不按我的预期工作。 – prajul
@prajul:是的,我现在正在摔跤类似的问题。表格视图是一个非常复杂的野兽。根据你使用的底层触摸,我尝试过的另一件事是将一个完全透明的UIView放在我的表格视图之上。如果你像上面的代码那样通过触摸,表格视图仍然不能正常工作(你可以点击它,但不能以任何方式滚动)。但是,如果您通过'hitTest:withEvent:'传递,则表视图将像正常一样工作,并且您可以在叠加uiview中使用初始hitTest来执行某些操作,如单击按钮或其他。 – MusiGenesis