I have an app that uses touch events to draw on the screen. I use UITouch locationInView
to return the CGPoint
of the touch. The problem is that the x and y coordinates are always the same — BUT only on 2nd generation devices running iOS 4.2.1 AND only when my app is built in Release mode. This also only seems to be a problem when taking touches directly from a touchesMoved
or touchesEnded
event object, since my buttons respond to touches correctly.
Thanks to a post at http://getmoai.com/forums/new-users/ios-touch-sensor-y-co-ordinate-always-the-same-as-x/ I was able to fix the problem by using the LLVM-GCC compiler rather than the newer LLVM 3.0 compiler and by using optimization level 0.
What is interesting is that using the GCC compiler corrected the touch locations I received in touchesEnded
while changing the optimization level to -O0
corrected the touch locations I received in touchesMoved
. I cannot explain why this is, but for now I'm ecstatic my app is working on these devices.
My questions then are — What are the downsides to delivering my app to the store using the older compiler? (I understand the impact of the optimization level.) And is there any way to configure the project so that I use the older compiler and lower optimization level only for iOS 4.2.1 and/or 2nd gen devices?
I am using this hack:
// not working (location.x == location.y)
CGPoint location = [touch locationInView:_myView];
//
// working!
static CGPoint location;
location = [touch locationInView:_myView];
//
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With