Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subclass of UIViewController don't catch touch event

I have a parent class (A) that is UIViewController. Than i create class B that is subclass of class A. What happens is that i can't catch touch events in class B with methods like touchesBegan. But if i implement this methods in class A ... they get called.

@interface A:UIViewController
.....

@interface B:A
like image 728
troner Avatar asked Sep 29 '10 15:09

troner


1 Answers

To use a UIViewController, must do event like:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch;
    CGPoint pos;

    for( touch in touches )
    {
        //pos = [ touch locationInView:self ]; // Only work on UIView
        pos = [touch locationInView:self.view ];       // Work on UIViewController

        //NSLog(@"Touch: %f, %f",pos.x,pos.y);

        // Send X, Y, tapcount
        _faceOff->toucheBegan( pos.x, pos.y, [ [ touches anyObject ] tapCount ]);
    }
}

Hope it help.

like image 114
vgonisanz Avatar answered Sep 20 '22 03:09

vgonisanz