0
我想使用iOS 7的coreMotion框架檢測設備震動。任何人都可以幫我解決這個問題嗎?通過CoreMotion檢測Shake手勢
我寫的代碼在我的viewDidAppear
CMMotionManager *motionManager = [[CMMotionManager alloc] init];
motionManager.deviceMotionUpdateInterval = 1.0/60.0;
__block double myAcceleration;
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMDeviceMotion *motion, NSError *error)
{
myAcceleration = motion.userAcceleration.y;
CATransform3D transform;
transform = CATransform3DMakeRotation(
motion.attitude.pitch, 1, 0, 0);
transform = CATransform3DRotate(transform,
motion.attitude.roll, 0, 1, 0);
transform = CATransform3DRotate(transform,
motion.attitude.yaw, 0, 0, 1);
}
];
下面描述,但沒有檢測到震動。
嘿,請分享你的答案,如果有人知道在覈心運動ios 7和以上的動搖 – Sudha