Reputation: 6270
I'm getting some really weird behavior in my iOS app. It works fine on the simulator and on new hardware, but when I test it with the Release configuration on an older-gen iPod Touch (software version 4.2.1) it doesn't work properly. This is my code to drag the object (a UIView subclass):
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.superview];
// Set the correct center when touched
touchPoint.x -= deltaX;
touchPoint.y -= deltaY;
NSLog(@"Touch moved1: %f %f, %f %f", touchPoint.x, touchPoint.y, self.center.x, self.center.y);
self.center = touchPoint;
NSLog(@"Touch moved2: %f %f, %f %f\n", touchPoint.x, touchPoint.y, self.center.x, self.center.y);
}
This is the resulting log output:
Touch moved1: -43.000000 45.000000, 45.000000 41.000000
Touch moved2: 45.000000 45.000000, 45.000000 41.000000
Touch moved1: -44.000000 45.000000, 45.000000 41.000000
Touch moved2: 45.000000 45.000000, 45.000000 41.000000
As you can see, somehow the assignment self.center = touchPoint
changes the value of touchPoint
. Instead of following your finger as you drag, the x and y values touchPoint
become equal to the touchPoint.y
, which contrains the movement to that diagonal. Any suggestions?
Upvotes: 1
Views: 64
Reputation: 9768
Is the device an ARM6 device?
There is a known bug in the ARM6 code generation in some versions of Xcode that causes problems like this. Try turning on the -mno-thumb option in the "other c flags" build setting section and see if it helps. If so, you can conditionally turn it on for ARM6 builds only.
See: This item
Upvotes: 1