views:

25

answers:

2

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
A: 

You need to implement those methods in your UIView subclasses, not in UIViewController subclasses.

Eiko
Hmmm ... i think i don't get it. I added some more info in my question.
troner
Everything works now. It was my mistake. I had some sort of bug. My subclassing works:) Thanks for answer!
troner
A: 

You need to subclass UIView to implement the method touchesBegan.

@interface YourCustomView : UIView

@implementation YourCustomView

// Override this function to get the touch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"TOUCH!");
}

And now set the view of your VC as a "YourCustomView"

@interface YourViewController : UIViewController
{
     YourCustomView*    view  
}
MathieuF
Yes, ok, but this changes the architecture. Is there really nothing i can do? Maybe link or enable something.
troner
I had the same problem recently and it changes only little in the architecture.
MathieuF
Everything works now. It was my mistake. I had some sort of bug. My subclassing works:) Thanks for answer!
troner