Jack G
Jack G

Reputation: 107

Why i can use locationInView but I can't use translationInVew

I have a UIPanGestureRecognizer, I can use the locationInView method, but when I type the traslationInView, I can't use it and the system says: No visible @interface for UIGestureRecognizer declares the selector 'translationInView'.

All the format should be all right. How is that?

Upvotes: 2

Views: 473

Answers (1)

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

It's because your reference is of type UIGestureRecognizer instead of UIPanGestureRecognizer.

As UIPanGestureRecognizer is subclass of UIGestureRecognizer so derived class members are not visible when you use super class refernce

Either type cast UIGestureRecognizer reference to UIPanGestureRecognizer

Or simple replace UIGestureRecognizer with UIPanGestureRecognizer in your method as

- (void)yourMethod:(UIGestureRecognizer *)recognizer 
{
}

Upvotes: 3

Related Questions