iOS Returning Views Beneath A Touch?


macrumors regular
Original poster
Feb 21, 2010
Hey, is there a way to have the views beneath a CGPoint returned? I have a script that is creating objects programmatically that aren't defined in the .h file and these views are added as subviews to the current view. I need to be able to interact with them at a later point. The only reason I don't define them in the .h is that I am expecting many of these views (Images) to be created. So can I interact with a view I created in an individual void?


macrumors 65816
Dec 29, 2010
Aartselaar // Antwerp // Belgium
You could do something like
for (UIView *view in someView) {
   if ([view isKindofClass:[UIImageView class]]) {
      //got the view pointer, do something with it.
     //In your script you can assign a TAG value, which u can use to retrieve the view
     if (view.tag == 23) {
         //Hooray, got it, do something awesome with it
I typed this out of my head, so you need to check some brackets/capitalisation etc.


macrumors regular
Apr 8, 2010
Chicago, IL
If you call hitTest:withEvent: on the superview of said subviews and pass in a CGPoint (event is optional), it will return the frontmost UIView at that CGPoint.