0

I have multiple UIImageViews placed producing an NxN grid view on a UIView added programmatically, and all have their userInteractionEnabled property set to YES.

EDITED

I now have another issue, where if I start dragging on a UIImageView and hover on other UIImageViews only the first one is calling touchesMoved method. E.g. a sample NSLog with the [[touches anyObject] view.tag] within touchesMoved method will print:

Log: touchesBegan for object with tag=123
Log: touchesMoved for object with tag=123
Log: touchesMoved for object with tag=123
...
Log: touchesEnded for object with tag=123

Is it any way to do that? I basically want to highlight the selected cell if the user drags over the UIImageViews dynamically.

Koray
  • 467
  • 1
  • 5
  • 12
  • Did you also implement the `touchesBegan`, `touchesEnded`, and `touchesCanceled` methods? And if so, are they getting called in the nominal sequence (began -> (typically multiple) moved -> ended)? You do need to implement all of these. – bobnoble Oct 20 '12 at 12:59
  • @bobnoble Obviously I had a mistake - i have been removing and re-adding UIImageView's as soon as the touchesBegan method was called and that was the reason. I have now edited the question, as I have a completely different issue. – Koray Oct 21 '12 at 21:16

1 Answers1

0

Try this:

if ([touch view] == img1) { 
   // move the image view
   img1.center = touchLocation;        
}
else if ([touch view] == img2) {
    // move the image view
   img2.center = touchLocation;        
}
Prasad Jadhav
  • 5,090
  • 16
  • 62
  • 80
  • My question does not involve moving of any of the UIImageView's. I only want to highlight (e.g. change backgroundColor, or Image) the appropriate cell while user keeps dragging around the view. – Koray Oct 22 '12 at 06:16