Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get the subView at a particular point in a superView?

What I want is something like

-(UIView*) fromPoint: (CGPoint) point inView:(UIView*) superView

Is something like this already present? I want it so that I can successfully swap contents of any two UIImageView out of many if one is dragged and dropped on another.

One way of doing it is by checking for all the subviews if they contain the provided point. Is there any other way?

Thanks.

like image 823
vishalv2050 Avatar asked Aug 06 '12 13:08

vishalv2050


1 Answers

Doing a hitTest on a UIView will return its subview if the hit test is on a view in its hierarchy

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

event would be nil for what you want

like image 94
wattson12 Avatar answered Sep 18 '22 17:09

wattson12