TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.