0
我有一个捏缩放手势的问题,主要问题是,当我缩放我放大视图的中心,所以如果我捏在右上角或底部放大总是在中心看法。 这是我的代码,我怎样才能编辑它在缩放触摸的中间进行缩放?核心小区缩放 - pinchgesture
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)gestureRecognizer{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
scala = [gestureRecognizer scale];
nextScala = [gestureRecognizer scale];
//NSLog(@"Scala: %f Gesture Scala %f",scala,[gestureRecognizer scale]);
}
else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) {
//CGPoint pointUno = [gestureRecognizer locationOfTouch:0 inView:[gestureRecognizer view]];
//CGPoint pointDue = [gestureRecognizer locationOfTouch:1 inView:[gestureRecognizer view]];
CGPoint point = [gestureRecognizer locationInView:[gestureRecognizer view]];
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
double minX = plotSpace.xRange.minLimitDouble;
double maxX = plotSpace.xRange.maxLimitDouble;
double minY = plotSpace.yRange.minLimitDouble;
double maxY = plotSpace.yRange.maxLimitDouble;
//NSLog(@"Scala: %f Gesture Scala %f Velocity: %f",scala,[gestureRecognizer scale],[gestureRecognizer velocity]);
double lenghtX = maxX - minX;
double lenghtY = maxY - minY;
float stepScale = lenghtX/25;
if ([gestureRecognizer scale] < nextScala) {
minX = plotSpace.xRange.minLimitDouble - stepScale;
maxX = plotSpace.xRange.maxLimitDouble + stepScale;
minY = plotSpace.yRange.minLimitDouble - stepScale;
maxY = plotSpace.yRange.maxLimitDouble + stepScale;
}
else {
minX = plotSpace.xRange.minLimitDouble + stepScale;
maxX = plotSpace.xRange.maxLimitDouble - stepScale;
minY = plotSpace.yRange.minLimitDouble + stepScale;
maxY = plotSpace.yRange.maxLimitDouble - stepScale;
}
lenghtX = maxX - minX;
lenghtY = maxY - minY;
NSLog(@"Old X: %f Y: %f",point.x,point.y);
NSLog(@"New X: %f Y: %f",lenghtX-point.x,lenghtY-point.y);
if (lenghtX > 0.05 && lenghtX < 4500) {
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(minX) length:CPTDecimalFromFloat(lenghtX)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(minY) length:CPTDecimalFromFloat(lenghtY)];
nextScala = [gestureRecognizer scale];
}
}
else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
[self performSelectorInBackground:@selector(getValues) withObject:nil];
// [self getValues]; } }
我需要改变阵列值,并做到这一点在此我喜欢使用大量的内存,我需要改变的值时,冲完了。我检测到hostingview捏手势,现在似乎工作 – kikko088 2013-05-01 09:07:49