0

I am using a CMMotionManager object to retrieve a CMAcceleration vector that indicates the acceleration of the device. This vector is in device coordinates, independently of the orientation of the GUI, and therefore independent of the orientation of my UIView.

However, when drawing into my UIView, I would like to convert that acceleration vector into the coordinate system of my UIView. Previously, I would read the device interface orientation from [UIApplication statusBarOrientation], or get device orientation changes via the [UIViewController willRotateToInterfaceOrientation] messages.

However, Apple is deprecating both of these in favor of treating all device orientation changes as changes in the frames of UIView objects. So, how are we supposed to convert between the device coordinate system of CMAcceleration, to the interface orientation of our UIView? What is the correct way to do this now?

EdSanville
  • 113
  • 7
  • Nobody has any idea? – EdSanville Nov 21 '15 at 14:32
  • Check out the answer I posted [here](http://stackoverflow.com/questions/25691721/how-do-i-adjust-cmmotionmanager-data-for-orientation-under-ios-8/38512223#38512223). If it answers your question, you might want to flag yours as a duplicate. –  Jul 21 '16 at 22:02
  • Hi, sorry for the late response. I can't seem to flag it as a duplicate. Clicking "flag," there's no option for "duplicate." Searching, it says that flagging duplicates only requires a reputation of 15, and mine is 23, so I have no idea what's going on here. Anyway, thanks for the reply, this is exactly the solution I've been waiting for. – EdSanville Sep 07 '16 at 19:29
  • Looks like it's been taken care of. Anyway, glad I could help! –  Sep 08 '16 at 05:10
  • Hello again. I have one question about your solution. When I implement this method, it only gets called when the interface orientation actually changes while using the app. What if the user starts the app in landscape mode, for example? What is the correct way of knowing the interface orientation on app startup? – EdSanville Dec 10 '16 at 13:59
  • I don't know of a clear-cut way. The new API seems designed to avoid having two separate layouts based on the device orientation. If your app launches into, EG, portrait orientation while landscape is supported, it will transition normally after launching. The counter-rotation technique works on a relative basis: it keeps some views oriented to match the device orientation as it changes from its initial orientation. But the initial orientation of your views should still match the initial orientation of the view controller. Hope that helps. Let me know if it doesn't suit your use case. –  Dec 13 '16 at 19:32

0 Answers0