如何确定iPhone应用程序视图类中的点击位置坐标
我正在尝试制作一个连接四部iPhone的应用程序。我已经制作了自己的自定义 UIView 类,这是玩游戏的地方。但是,我尝试使用 TouchMoved、touchesEnded 等方法根据用户单击的位置检索数据(这样我就知道他们试图将片段放入哪一列)。我如何从 viewController 类获取此信息到我的 UIview 类?
i'm trying to make a connect four iphone app. I have made my own custom UIView class, which is where the game is played. However, I am trying to use the touchesMoved, touchesEnded, etc. methods to retrieve data based on where the user clicked (so i know which column they are trying to put a piece into). How can i get this information from the viewController class to my UIview class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只会使用
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
并可能覆盖- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent * )event
忽略我可能覆盖的视图中的触摸。它确实取决于您的视图层次结构。I would just use
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
and potentially override- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
to ignore touches in views that I may have overlaid. It does depend on your view hierarchy really.