2012-10-10 75 views
2

我剛剛下載了C4,並試圖在一些示例代碼中獲得捏手勢,我已經有了滑動手勢。代碼如下:只要我添加具有捏我得到的編譯以下錯誤消息,這似乎不可思議給出箍縮在下面的錯誤消息中提到的列表中列出的第二行C4中是否支持捏手勢?

[ball addGesture:SWIPERIGHT name:@"swipeR" action:@"swipeBall"]; 
[ball addGesture:PINCH name:@"pinch" action:@"zoomBall"]; 

。任何想法是怎麼回事?

錯誤消息:

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)

回答

1

不幸的是,我還沒有實現縮放手勢呢。該變量可用,就像佔位符一樣。我希望儘快將其加入到API中。

0

我想我設法實現了這一點。

我走進c4CanvasController並已將此添加到addGesture方法:

case PINCH: 
      recognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:NSSelectorFromString(methodName)]; 
      break; 

然後我說的姿態,以項目爲平常:

[self addGesture:PINCH name:@"pinchme" action:@"customPinchMethod:"]; 

我定義了一個捏和縮放像行爲捏手勢回調方法。

-(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; 

}