我设法使用 touchesMoved 和 touchesEnded 进行滑动操作
虽然主要思想是使用触摸的坐标调用 UIIMageViews,并将其与 touchesMoved 函数中的 UIImageViews 坐标进行比较
使用标志禁用已编辑的 UIIMageViews(当我在同一个触摸会话中时,手指仍在屏幕上)并刷新 UIImageViews 以在 touchesEnded 中再次可编辑
func swipeTouches(touches: NSSet!) {
// Get the first touch and its location in this view controller's view coordinate system
let touch = touches.allObjects[0] as! UITouch
let touchLocation = touch.locationInView(self.view)
for pixel in pixelArrays {
// Convert the location of the obstacle view to this view controller's view coordinate system
let pixelViewFrame = self.view.convertRect(pixel.pixelImage.frame, fromView: pixel.pixelImage.superview)
// Check if the touch is inside the obstacle view
if CGRectContainsPoint(pixelViewFrame, touchLocation) {
// check if the pixel is Editable
if(!pixel.isEditable){
let index = pixel.index
pixelArrays.insert(updatePixel(index) , atIndex: index)
}
}
}
}
我现在唯一的问题是,如果在其中一个 UIImageViews 上开始滑动,touchesMoved 函数将其视为要查找坐标的视图,而其他 UIImageViews 不受影响
我解决这个问题的想法是在所有 UIImageViews 顶部添加图层并禁用他们已经拥有的点击识别并使用坐标方式实现点击。
我很高兴知道是否有其他方法可以做到这一点
更新:
我设法通过我写的东西来解决上面的问题,但我没有添加另一层,而是禁用了所有 UIImageViews 上的触摸,并使用触摸坐标和它们调用它们
非常感谢