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