40media Trying to reolve touch to location always returns zero (0) as x location

Trying to reolve touch to location always returns zero (0) as x location

While writing the touchesBegan handler for my view I ran into this interesting error.


... UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; ... 

The problem is point.x is always zero, no matter where I "touch" and y is a huge number that flunctuates somewhere between 1070000000 and 1090000000.

The handles is in a view class and it works the same is I pass nil instead of self to locationInView. I also tried looping over all of the touches, and there is only that one with x as zero always.

So what am I doing wrong here?

Sending iphone videos to a server


Can give different color in CGContextSetRGBFillColor?
Any chance you're using NSLog(@"%d, %d", point.x, point.y); to print out the point values? It sounds kind of like a float -> int conversion error.

How can I move around and slide away a UIView with touches and swipes?
I've used locationInView: a lot, and I've never had a problem like this.

C# to iPhone dev [closed]
iPhone web apps running as native apps
You might also try checking [self frame] to make sure it's nonzero..
Javascript for “Add to Home Screen” on iPhone?

What's the best way to communicate between view controllers?

How can I scan barcodes on iOS?


Ben is right.

The problem is when you try to print the value using %d in NSLog, because point.x and point.y are float values..

94 out of 100 based on 54 user ratings 754 reviews