Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios5 如何将UILongPress手势识别器应用于C4中的形状?_Ios5_C4 - Fatal编程技术网

Ios5 如何将UILongPress手势识别器应用于C4中的形状?

Ios5 如何将UILongPress手势识别器应用于C4中的形状?,ios5,c4,Ios5,C4,我在C4工作,希望能够按下一个形状,并以缓慢的速度向上拖动它。 我一直在学习“为UIGestureRecognitor获取UITouch对象”教程和其他TouchsMoved和TouchsBegind Objective-C教程,但手势不适用于形状。项目将生成,但按住并拖动形状时,形状仍不会移动。C4是否有一种特殊的方式将手势应用于形状 这是我的代码: Draggesturererecognizer.h #import <UIKit/UIKit.h> @interface Dra

我在C4工作,希望能够按下一个形状,并以缓慢的速度向上拖动它。 我一直在学习“为UIGestureRecognitor获取UITouch对象”教程和其他TouchsMoved和TouchsBegind Objective-C教程,但手势不适用于形状。项目将生成,但按住并拖动形状时,形状仍不会移动。C4是否有一种特殊的方式将手势应用于形状

这是我的代码:

Draggesturererecognizer.h

#import <UIKit/UIKit.h>


@interface DragGestureRecognizer : UILongPressGestureRecognizer {

 }

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

@end

@protocol DragGestureRecognizerDelegate <UIGestureRecognizerDelegate>
- (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches     andEvent:(UIEvent *)event;
@end

C4具有一种简化向任何可见对象(例如C4Shape、C4Movie、C4Label…)添加手势过程的方法

注意:您需要创建C4Shape的子类,您可以在其中创建一些自定义方法

例如,以下内容将向C4形状添加轻触手势:

C4Shape *s = [C4Shape rect:CGRectMake(..)];
[s addGesture:TAP name:@"singleTapGesture" action:@"tap"];
C4Control文档中列出了添加手势:名称:操作:方法,其定义如下:

向对象添加手势

- (void)addGesture:(C4GestureType)type name:(NSString *)gestureName action:(NSString *)methodName
(C4GestureType)类型可以是以下任一类型:

  • 水龙头
  • 泳镜
  • 游泳池
  • 游泳
  • 游泳池
  • 平底锅
  • 朗普尔斯
以下手势可用,但尚未测试:

  • 轮换
(NSString*)手势名称
允许您为手势指定唯一的名称

(NSString*)方法名
允许您指定手势将触发的方法

所以。。。回到上面的例子:

[s addGesture:TAP name:@"singleTapGesture" action:@"tap"];
…将在
s
对象中添加一个名为
singletappostate
TAP
手势,触发后,该手势将运行
-(无效)轻触方法(需要在类中已经定义)


您可以应用我上面描述的技术,但可以使用:

[s添加手势:平移名称:@“平移”操作:@“移动:;

您还必须定义一个

-(无效)移动:(id)发送者;

方法在形状的类中

[s addGesture:TAP name:@"singleTapGesture" action:@"tap"];