in my app, when the user touches on the view
,i am showing an UIImageView
there and i drag and
drop the image from another UIImageView
to that touched UIImageView
.
But the problem is that, only the recent touched UIImageView
is activated. i mean ,when i
click 3 times then shows 3 UIImageViews
but only the last is activated and accept the another
image.
How can i make all touched UIImageViews
are activated .. Any开发者_StackOverflow body help on this..
Thanks in advance.
You should read Apples documentation on the responder chain and event handling. The key UIView method here is
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
This method traverses the view hierarchy by sending the pointInside:withEvent: message to each subview to determine which subview should receive a touch event. If pointInside:withEvent: returns YES, then the subview’s hierarchy is traversed; otherwise, its branch of the view hierarchy is ignored. You rarely need to call this method yourself, but you might override it to hide touch events from subviews.
You should try this: Where there is your UIView (Or a view):
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapped:)];
tapGesture.numberOfTapsRequired = 1;//number of tap
[view addGestureRecognizer:tapGesture];
The selector:
-(void)tapped:(UITapGestureRecognizer *)sender {
NSLog(@"Pressed");
}
精彩评论