在单个视图iPhone应用程序中,我有以下结构:scrollView -> contentView -> imageView
和底下(在主视图中)有7个可拖动的自定义视图 - 可以从/拖到contenView
。处理触动从主视角开始 - 如何查看触摸的子视图?
最初拖动是在自定义视图中处理的(请参阅[email protected]),虽然此功能运行良好,但需要将通知发送到主视图。
因此,我试图将touchesBegan
和朋友移至主应用视图(请参阅3210)。
我的问题是:
最初我在contentView
(见GameBoard.m)有这个代码,以使子视图在scrollView
拖:从
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView* result = [super hitTest:point withEvent:event];
return result == self ? nil : result;
}
但是试图拖动互动时回contentView
到主视图(在下面的屏幕截图所示的方向),这不会提供touchesBegan
到主视图。
所以我已经改变了这个方法返回主视图,而不是砖:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView* result = [super hitTest:point withEvent:event];
return result == self ? nil : self.window.rootViewController.view;
}
现在touchesBegan
被称为主视图(如我可以在调试器中看到的),但touches.view
也指向主视图。
我的问题是:
如何找到新touchesBegan
方法接触的瓦片?