I want to find tilt in all side (left, right, forward, backward)
I have use below code to find left and right
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *deviceMotion, NSError *error)
{
if (deviceMotion.attitude.roll <= -1)
{
[self TiltControl:@"left"];
}
else if(deviceMotion.attitude.roll > 1)
{
[self TiltControl:@"right"];
}
}];
now how can find forward and backward...
what is the best way to find all 4 tilt...
Just use the
attitude.pitch
property:There is also rotation around Z axis, available as
attitude.yaw
. Credits to NSHipster.