Из здесь,
Я узнал, что Tap Pressure можно определить по показаниям акселерометра. Но коду, доступному по ссылке, уже 3 года, и Apple заменила UIAccelerometer на CoreMotion. У меня есть приведенный ниже код для измерения ускорения по трем осям:
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 ];
}];
}
}
Есть ли способ определить давление касания с помощью CoreMotion?