I'm using the touchesBegan
method in my main UIView to create a second UIView and add it as a subView. What I'd like to be ab开发者_运维问答le to do is to have the second UIView get the touchesEnded
event when I lift my finger up. I don't seem to be able to do this - the original UIView that I tapped always receives the touchesEnded
event.
Edit: the reason I have to find some way to "transfer" the touchesEnded
is that the initial touchesBegan
is received by a UIView that is removed as a subView at the same time the new UIView is added, so the touchesEnded
actually fires immediately as the subView is removed.
Hm what I would do is the following:
- touchesEnded
{
if( yourViewIsThereAsSubView )
{
// pass on the event to the other view
[yourSubView touchesEnded];
return;
}
// normal behaviour
[super touchesEnded];
}
I don't think you can have the new UIView get the touchesEnded event. You'll probably have to resort to getting the location of a touch in the touchesEnded event, then ask the parent view which subview contains that location.
精彩评论