2

From here,

I got to know that Tap Pressure can be detected using accelerometer readings. But the code available in the link is 3 years old and Apple has replaced UIAccelerometer with CoreMotion. I have the below code to measure acceleration about three axes:

motionManager = [[CMMotionManager alloc]init];
motionManager.deviceMotionUpdateInterval = 1;
[motionManager startDeviceMotionUpdates];
timer = [NSTimer scheduledTimerWithTimeInterval:(1) target:self selector:@selector(read) userInfo:nil repeats:YES];

if([motionManager isGyroAvailable]){
    if(![motionManager isGyroActive]){
        [motionManager setGyroUpdateInterval:1.0];
        [motionManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMGyroData *gyroData,  NSError *error){
            accelerationX.text = [[NSString alloc]initWithFormat:@"%0.2f", gyroData.rotationRate.x ];
            accelerationY.text = [[NSString alloc]initWithFormat:@"%0.2f", gyroData.rotationRate.y ];
            accelerationZ.text = [[NSString alloc]initWithFormat:@"%0.2f", gyroData.rotationRate.z ];
        }];
    }
}

Is there any way I can detect Tap Pressure using CoreMotion?

Community
  • 1
  • 1
Vamshi Krishna
  • 979
  • 9
  • 19

0 Answers0