gpt4 book ai didi

iphone - 当触摸移动时找到我们触摸下的物体

转载 作者:行者123 更新时间:2023-11-28 22:50:44 25 4
gpt4 key购买 nike

如何确定我悬停或拖动的对象下方的属性或对象?

为了清楚地提出我的问题,假设我正在悬停一个 uiview,我想找出我正在悬停的 View 下面有什么(对象或 View )。

最佳答案

在自定义 View 中,您可以覆盖 touchesEnded 方法。此示例代码可能有助于解决您的自定义 View HitTest 问题。

 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

if ([touches count] == 1) {
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:custom_view];

if (CGRectContainsPoint(custom_view.bounds, point)) {
//if touch hit to custom_view
};
}
[super touchesEnded:touches withEvent:event];
}

关于iphone - 当触摸移动时找到我们触摸下的物体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12067282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com