1
我開發了一個使用CoreMotion獲取傾斜信息的小應用程序。如何讓CoreMotion代碼在視網膜iPod touch設備上工作?
但它不適用於iPod touch。我使用iOS 5.1在第一臺視網膜顯示器iPod touch上進行了測試。 gyroAvailable屬性返回YES,所以我認爲這個iPod確實有陀螺儀。
此代碼工作正常在iPhone 4:
CMMotionManager *mm = [[CMMotionManager alloc] init];
self.motionManager = mm;
[motionManager setDeviceMotionUpdateInterval:0.05];
CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
[self handleMotion:motion error:error];
};
[motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical toQueue:[NSOperationQueue currentQueue] withHandler:motionHandler];
startDeviceMotionUpdatesUsingReferenceFrame
似乎是罪魁禍首,但我不能從文檔弄清楚,這種方法不會對它們沒有什麼可陀螺儀的設備。
我需要的是精確輸出用戶在縱向模式下向左或向右傾斜設備的程度。
我還有什麼替代方案?