2012-01-31 77 views
1

我在我的iOS应用程序中出现一些非常奇怪的行为。它可以在模拟器和新硬件上正常工作,但是当我使用旧版iPod Touch(软件版本4.2.1)上的Release配置进行测试时,它无法正常工作。这是我的代码来拖动对象(UIView子类):分配导致意外的结果与特定的iOS配置

- (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); 
} 

这是生成的日志输出:

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 

正如你所看到的,不知何故分配self.center = touchPoint改变的touchPoint值。当您拖动时,您的手指不会跟随您的手指,x和y的值touchPoint会变得等于touchPoint.y,这会禁止移动到对角线。有什么建议么?

回答

1

设备是ARM6设备吗?

在某些版本的Xcode中存在一个已知的ARM6代码生成错误,导致类似这样的问题。尝试打开“其他c标志”版本设置部分中的-mno-thumb选项,看看它是否有帮助。如果是这样,您可以有条件地将其打开,仅用于ARM6构建。

参见:This item

+0

完美解决了这个问题。谢谢! – Ned 2012-01-31 23:20:01