我刚刚下载了C4,并正在尝试在一些示例代码中使用收拢手势,其中我已经使用了swipe手势。代码如下:
[ball addGesture:SWIPERIGHT name:@"swipeR" action:@"swipeBall"];
[ball addGesture:PINCH name:@"pinch" action:@"zoomBall"];一旦我添加了带有PINCH的第二行,我就会得到以下关于编译的错误消息,这看起来很奇怪,因为PINCH列在下面的错误消息列表中。知道怎么回事吗?
错误消息:
2012-10-10 00:58:06.166 Test[24121:10703] *** Assertion failure in -[MyBall addGesture:name:action:], /Users/moi/Development/C4Installer/libC4/libC4/C4Control.m:319
2012-10-10 00:58:06.184 Test[24121:10703] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The gesture you tried to use is not one of: TAP, PINCH, SWIPERIGHT, SWIPELEFT, SWIPEUP, SWIPEDOWN, ROTATION, PAN, or LONGPRESS'
*** First throw call stack: (0x320022 0x1730cd6 0x2c8a48 0x99c2cb 0xcdd3 0x380b 0x3190 0xe2b386 0xe2c274 0xe3b183 0xe3bc38 0xe2f634 0x3c2eef5 0x2f4195 0x258ff2 0x2578da 0x256d84 0x256c9b 0xe2bc65 0xe2d626 0x2d3d 0x2ca5) terminate called throwing an exception(lldb)
发布于 2012-10-11 11:46:30
不幸的是,我还没有实现夹击手势。变量是可用的,就像占位符一样。我希望很快就能把它放入API中。
发布于 2014-01-21 08:13:06
我想我成功地实现了这一点。
我进入c4CanvasController并将以下代码添加到addGesture方法:
case PINCH:
recognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:NSSelectorFromString(methodName)];
break;然后,我像往常一样将手势添加到项目中:
[self addGesture:PINCH name:@"pinchme" action:@"customPinchMethod:"];我为pinch手势回调方法定义了一个类似收缩和缩放的行为。
-(void)customPinchMethod:(UIPinchGestureRecognizer*)sender {
NSLog(@"Pinching");
NSLog(@"latscale = %f",mLastScale);
mScale = sender.scale*mLastScale;
if (sender.state == UIGestureRecognizerStateEnded) mLastScale = mScale;
CGAffineTransform currentTransform = CGAffineTransformIdentity;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, mScale ,mScale);
self.view.transform = newTransform; }
https://stackoverflow.com/questions/12814787
复制相似问题