How can I tell if an iPhone rotates face up in a table?

Is there a way to determine if the iphone lying on the table rotates face up ?. I really understand that this type of movement is not reported by the accelerometer, nor does it report the interface of the (BOOL) toAutorotateToInterfaceOrientation: (UIInterfaceOrientation) method.

Is there a way to detect angle changes for a phone spinning this way ?. Thank.

+3
source share
4 answers

The gravity vector will be constant when it rotates on a flat table, so you will not see anything on the accelerometers. You can follow compass changes to detect this rotation, but only on iPhone 3G S. For more details see CLLocationManager , see the header methods.

EDIT . With iPhone 4, you can detect rotation using gyroscopes. In iOS 4, there is a new CMMotionManager class for getting rotation speed from gyroscopes.

+9
source

When the phone is stationary, the sum of the acceleration vectors must be +1. When the phone rotates (provided that the sensor is offset from the center), the sum of the vectors should be greater than 1 and (hopefully) somewhat constant.

, , , , .

alt text

AccelerometerGraph Apple.

+5

, , iPhone . , .

+4

, , 2g itouch, x y ( 2g , ). , , , . , , . shouldAutorotateToInterfaceOrientation, sdk , , .

+2
source

Source: https://habr.com/ru/post/1737248/


All Articles