disable pointer when enlarged image is hidden

Change-Id: I6c637a4d8d8e0e3ffdeeb29ea98ca184d198355e
This commit is contained in:
siqi
2013-07-12 16:25:57 +02:00
parent 135cb84e76
commit 08225e9213
2 changed files with 52 additions and 48 deletions

View File

@@ -65,9 +65,9 @@
- (void)startMotionDetect
{
// __block float stepMoveFactorX = 5;
// __block float stepMoveFactorY = 5;
// __block double refX, refY;
// __block float stepMoveFactorX = 5;
// __block float stepMoveFactorY = 5;
// __block double refX, refY;
[self.motionManager
startAccelerometerUpdatesToQueue:[[NSOperationQueue alloc] init]
@@ -84,12 +84,12 @@
// refY = data.acceleration.y;
// self.pointerCalibrationOn = NO;
// }
// float movetoX = rect.origin.x + ((data.acceleration.x - refX) * stepMoveFactorX);
// float movetoX = rect.origin.x + ((data.acceleration.x - refX) * stepMoveFactorX);
float movetoX = self.touchPointerImage.frame.origin.x + self.touchPointerImage.frame.size.width * ABS(data.acceleration.x - self.refLeftUpperGravity.x) / ABS(self.refRightUpperGravity.x - self.refLeftUpperGravity.x);
float maxX = self.touchPointerImage.frame.origin.x + self.touchPointerImage.frame.size.width - rect.size.width;
// float movetoY = (rect.origin.y) + ((data.acceleration.y - refY) * stepMoveFactorY);
// float movetoY = (rect.origin.y) + ((data.acceleration.y - refY) * stepMoveFactorY);
float movetoY = self.touchPointerImage.frame.origin.y + self.touchPointerImage.frame.size.height * ABS(data.acceleration.y - self.refRightUpperGravity.y) / ABS(self.refRightLowerGravity.y - self.refRightUpperGravity.y);
float maxY = self.touchPointerImage.frame.origin.y + self.touchPointerImage.frame.size.height;
@@ -186,6 +186,7 @@
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (!self.touchPointerImage.isHidden){
UITouch *touch = [[event allTouches] anyObject];
CGPoint loc = [touch locationInView:self.touchPointerImage];
if (loc.x >= 0 && loc.x <= self.touchPointerImage.frame.size.width
@@ -196,10 +197,12 @@
self.movingPointer.center = p;
[self.movingPointer setHidden:NO];
}
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.touchPointerImage.isHidden){
UITouch *touch = [[event allTouches] anyObject];
CGPoint loc = [touch locationInView:self.touchPointerImage];
if (loc.x >= 0 && loc.x <= self.touchPointerImage.frame.size.width
@@ -210,6 +213,7 @@
p.y = loc.y + self.touchPointerImage.frame.origin.y;
self.movingPointer.center = p;
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event