2012-03-27 32 views

回答

2

属性(NSSet *)touches包含UITouch对象每个都包含几个有用的属性:

@property(nonatomic, readonly) NSUInteger tapCount 
@property(nonatomic, readonly) NSTimeInterval timestamp 
@property(nonatomic, readonly) UITouchPhase phase 
@property(nonatomic,readonly,copy) NSArray *gestureRecognizers 

typedef enum { 
    UITouchPhaseBegan, 
    UITouchPhaseMoved, 
    UITouchPhaseStationary, 
    UITouchPhaseEnded, 
    UITouchPhaseCancelled, 
} UITouchPhase; 

阶段和tapCount是非常有用的属性标识的类型触摸。 检查您是否可以使用UIGestureRecognizers。 NSArray *gestureRecognizers - 与此特定触摸相关的此对象的数组。

祝你有美好的一天:)

2

您可以使用手势识别:

首先,你需要注册的手势识别:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] 
             initWithTarget:self 
             action:@selector(handleTap:)]; 
[myView addGestureRecognizer:tap]; 

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
             initWithTarget:self 
             action:@selector(handleLongPress:)]; 
longPress.minimumPressDuration = 1.0; 
[myView addGestureRecognizer:longPress]; 

然后,你必须写操作方法:

- (void)handleTap:(UITapGestureRecognizer *)gesture 
{ 
    // simple tap 
} 

- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture 
{ 
    // long tap 
} 
相关问题