Bir kullanıcının iPhone'unu başka bir nesnede ne zaman kullandığını algılamaya çalışırken, telefonlarını salladığında. İstediğim kadar mükemmel çalışmasını sağlayamıyorum, çünkü ya çok fazla çarpma, çarpma ya da bir sarsıntı yumru olduğunu düşünüyor.CoreMotion Bump vs. iPhone üzerinde Sarsıntı
Birisi aşağıdaki koduma bakıp öneri sunabilir mi? Birinin ya da diğerinin olduğundan emin olmalıyım.
// SHAKING
- (void) motionEnded: (UIEventSubtype) motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
[self setNumberOfShakes: [self numberOfShakes] + 1];
[self reloadAllTapShakeData];
}
}
// TAPPING & BUMPING
- (void) setupAccelerometerMonitoring
{
[self setManager: [[CMMotionManager alloc] init]];
if ([[self manager] isDeviceMotionAvailable])
{
[[self manager] setDeviceMotionUpdateInterval: 0.02];
[[self manager] startDeviceMotionUpdatesToQueue: [NSOperationQueue mainQueue] withHandler: ^(CMDeviceMotion * _Nullable motion, NSError * _Nullable error)
{
//NSLog(@"x = %f | y = %f | z = %f", [motion userAcceleration].x, [motion userAcceleration].y, [motion userAcceleration].z);
if (([motion userAcceleration].x > .50 && [motion userAcceleration].x < 1)
|| ([motion userAcceleration].y > .70 && [motion userAcceleration].x < 1)
|| ([motion userAcceleration].z > .80 && [motion userAcceleration].z < 1))
{
NSLog(@"TAPPED ON ANOTHER OBJECT");
}
}];
}
}
Onların API'si artık çalışmıyor mu? Bir API anahtarı olmaması, bu hala işe yarayacak mı? –
Bunu denedim. Artık uyumlu değil. –