我正在研究如何在 iOS6 中使用 UIPanGestureRecognizer 做某事,并查看了头文件 UIPanGestureRecognizer.h 的一部分:
NS_CLASS_AVAILABLE_IOS(3_2) @interface UIPanGestureRecognizer : UIGestureRecognizer {
@package
CGPoint _firstScreenLocation;
CGPoint _lastScreenLocation;
NSTimeInterval _lastTouchTime;
id _velocitySample;
id _previousVelocitySample;
NSMutableArray *_touches;
NSUInteger _lastTouchCount;
NSUInteger _minimumNumberOfTouches;
NSUInteger _maximumNumberOfTouches;
CGFloat _hysteresis;
CGPoint _lastUnadjustedScreenLocation;
unsigned int _failsPastMaxTouches:1;
unsigned int _canPanHorizontally:1;
unsigned int _canPanVertically:1;
unsigned int _ignoresStationaryTouches:1;
}
@property (nonatomic) NSUInteger minimumNumberOfTouches; // default is 1. the minimum number of touches required to match
@property (nonatomic) NSUInteger maximumNumberOfTouches; // default is UINT_MAX. the maximum number of touches that can be down
- (CGPoint)translationInView:(UIView *)view; // translation in the coordinate system of the specified view
- (void)setTranslation:(CGPoint)translation inView:(UIView *)view;
- (CGPoint)velocityInView:(UIView *)view; // velocity of the pan in pixels/second in the coordinate system of the specified view
@end
我正在寻找与
CGPoint _firstScreenLocation;
这不是@property,所以它是私有的。
我的问题是:为什么我们能看到这些私人物品?鉴于它们是“私人的”,它们如何被使用?
我想也许是为了防止我们想要对对象进行子类化,所以我尝试这样做:
#import <UIKit/UIGestureRecognizerSubclass.h>
@interface MyPanGesture : UIPanGestureRecognizer
- (CGPoint) firstLocation;
@end
@implementation MyPanGesture
- (CGPoint) firstLocation
{
return self->_firstScreenLocation;
}
@end
但是由于链接错误而无法构建:
架构 armv7s 的未定义符号:“_OBJC_IVAR_$_UIPanGestureRecognizer._firstScreenLocation”,引用自:Gesture.o ld 中的 -[MyPanGesture firstLocation]:未找到架构 armv7s 的符号 clang:错误:链接器命令失败,退出代码为 1(使用-v 查看调用)
谁能帮助这个困惑的人?