【问题标题】:How to get the UIView object at the location of UITouch from - (void)touchesEnded:withEvent:?如何从 - (void)touchesEnded:withEvent: 获取 UITouch 位置的 UIView 对象?
【发布时间】:2016-08-30 09:53:49
【问题描述】:

我想在触摸被抬起的位置(离开屏幕)获取对象。

这将用于实现拖放,我有这些方法用于覆盖:

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;

在 touchesEnded:withEvent: 中使用 [[touches anyObject] view] 为我提供了我第一次触摸的 UIView 对象,但不是我释放触摸的位置。

使用[[touches anyObject] locationInView:self.view] 确实给了我释放触摸的位置,但我必须将坐标映射到 UIView。

【问题讨论】:

标签: objective-c drag-and-drop uitouch uiresponder touchesended


【解决方案1】:

这个问题的答案是在另一个措辞不同的问题中回答的。

@Ronak Chaniyara 回答:https://stackoverflow.com/a/16329436/3920809

【讨论】:

    猜你喜欢
    • 2013-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多