UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

UITouch coordinates

Forums > Swift

Hi,

Ok this has been driving me nuts for days now. I have a UIImageView as a child of UIView. I load an image into the UIImageView and set the view's frame size. But now when I read UITouch's, the point coordinates are not what I expect. I want UITouch to send me the coordinates in the same range as the UIImageView frame size. I've tried changing the view in touch.location(in: myUIImageView) but I can only assume UITouch is gving me coordinates based of the main UIView? How do you resize the main UIView or get UITouch to give me the coordinates from the image view frame size?

Thanks for any advice given.

Mark

2      

More info:

If I print out view.frame.size, I get (896.0, 414.0). If I print out the points I get from UITouch, they seem to be in that range.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.