Forwarding UIGesture to views behind

后端 未结 5 1352
长情又很酷
长情又很酷 2020-11-29 20:21

I am working on an iphone (iOS 4.0 or later) app and having some troubles with touch handling between multiple views. I am having a view structure like this

         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 20:59

    If bView has pinch gesture. From bView's pinch gesture action if called aView's pinch gesture action then...

    UIPinchGestureRecognizer *pinchA   =  [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(handlePinchA:)];
    [aView addGestureRecognizer:pinchA];
    [pinchA release];    
    
    UIPinchGestureRecognizer *pinchB   =  [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(handlePinchB:)];
    [bView addGestureRecognizer:pinchB];
    [pinchB release];
    
    
    -(void)handlePinchA:(UIGestureRecognizer*)gestureRecognizer
    {
    NSLog(@"handlePinch on A");  
    }
    
    -(void)handlePinchB:(UIGestureRecognizer*)gestureRecognizer
    {
    NSLog(@"handlePinch on B");
    [self handlePinchA:gestureRecognizer];  
    }
    

    aView is a thirdParty lib. Can you call handlePinchA method from outside? NSLog gestureRecognizers prints me action=handlePinchA

    NSLog(@"gestureRecognizers %@", [aView gestureRecognizers]);
    

    Prints me:

    gestureRecognizers (
    "; target= <(action=handlePinchA:, target=....
    

提交回复
热议问题