0
我有一個具有自定義drawRect()方法的UIView,用於某些繪圖。iOS UIPinchGestureRecognizer在UIGestureRecognizerStateEnded狀態下獲取與未知源的偏移
我使用UIPinchGestureRecognizer實現縮放效果。
這是操作方法:
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer
{
//NSLog(@"Pinch gesture recognized");
CGPoint touchOrigin = [recognizer locationInView:self];
_currentScaleOrigin = touchOrigin;
if (recognizer.state == UIGestureRecognizerStateEnded)
{
NSLog(@"%[email protected] x = %f, y = %f", @"Pinch end:", touchOrigin.x, touchOrigin.y);
return;
}
if (recognizer.state == UIGestureRecognizerStateChanged)
{
//NSLog(@"scale = %f", recognizer.scale);
NSLog(@"%[email protected] x = %f, y = %f", @"Pinch origin:", touchOrigin.x, touchOrigin.y);
// scale has at start a value of 1.0 and increases as fingers moves away from each other
_currentScaleLevel += recognizer.scale - 1;
[self setNeedsDisplay]; // call drawRect for redrawing at current scale level
}
recognizer.scale = 1;
}
當接收UIGestureRecognizerStateEnded
消息我得到一些奇怪的偏移座標:
Pinch origin: x = 358.000000, y = 630.000000
Pinch origin: x = 355.000000, y = 627.000000
Pinch origin: x = 353.000000, y = 625.000000
Pinch origin: x = 351.000000, y = 624.000000
Pinch origin: x = 351.000000, y = 623.000000
Pinch origin: x = 350.000000, y = 622.000000
Pinch origin: x = 349.000000, y = 622.000000
Pinch origin: x = 349.000000, y = 622.000000
Pinch end: x = 315.000000, y = 750.000000
...和翻譯免費:)我不需要。 我不知道翻譯來自哪裏。
如何禁用此翻譯?