title: Track the Device Motion in iPhone
body: <blockquote>
    <p>I want to track the device's movement along X-axis in a straight line
    just like panorama.</p>
  </blockquote>
  
  <p>I try with Accelerometer but can't able to track this.</p>
  
  <p>I think it only detect the Device Rotation. I search a lot for the tutorial of Grayscope, Magnetometer, etc.</p>
  
  <p><strong>Any one can give the sample of the Core motion?</strong></p>
  
  <p>Help me to solve this.</p>
  
  <p>Thank you.</p>
  
  <p>My code is as follow:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      xval=0;
      motionManager = [[CMMotionManager alloc] init];
      motionManager.deviceMotionUpdateInterval = 1.0/60.0;
      NSOperationQueue *aQueue = [NSOperationQueue alloc];
      [motionManager startDeviceMotionUpdatesToQueue:aQueue withHandler:^(CMDeviceMotion *motion, NSError *error) {
          NSLog(@"X value is: %f", motion.userAcceleration.x);
          if (motion.userAcceleration.x &gt; 0.05) {
              //a solid move forward starts
              //lineLength++; //increment a line length value
              xval=xval+10;
              ball.frame=CGRectMake(xval, 361, 119, 104);
          }
          if (motion.userAcceleration.x &lt; -0.02 ) {
              [motionManager stopDeviceMotionUpdates];
          }
      }];
  }
  </code></pre>