Search code examples
iosobjective-cimage-rotationcompass-geolocation

Prevent UIImageView from rotating with the device rotation


I am doing a compass and I dont want my uiimageview rotate when the user rotate the device. Is it possible to disable this?

Thanks you.


Solution

  • OK, it took me a while to work out what you actually wanted.

    Your question would be better phrased something like...

    I'm trying to make a compass app. Using an image as the compass. Can I keep it pointing in the same direction when the user rotates the device.

    The answer to this is yes.

    You need to look at using the CoreMotion framework.

    JUST A QUICK NOTE

    By doing this you are not "preventing it from rotating". You are actually rotating the image on the screen to give the illusion that it is not rotating.