我想简单地使用NSLog输出新iPhone 4陀螺仪的输出。但是在阅读文档并按照示例代码进行操作后,我出现了以下错误。
即使我只是独立地使用[[CMMotionManager alloc] init];来设置我的motionManager对象,而没有其他代码,我仍然会收到错误信息。
这是我的.h文件。
任何帮助和/或源代码,以简单地记录iPhone 4陀螺仪数据将不胜感激。非常感谢!
ERROR,Time,300635803.946,Function,"CLLoggingSetFile",could not open locations log /var/mobile/Library/Caches/CoreMotion/CoreMotion.log
即使我只是独立地使用[[CMMotionManager alloc] init];来设置我的motionManager对象,而没有其他代码,我仍然会收到错误信息。
这是我的.h文件。
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
@interface GyroTest0ViewController : UIViewController {
CMMotionManager *motionManager;
NSOperationQueue *opQ;
}
@end
这是我的.m文件。
- (void)viewDidLoad {
[super viewDidLoad];
// the error occurs even just with this line on its own
motionManager = [[CMMotionManager alloc] init];
if (motionManager.gyroAvailable) {
motionManager.gyroUpdateInterval = 1.0/60.0;
[motionManager startGyroUpdates];
opQ = [[NSOperationQueue currentQueue] retain];
CMGyroHandler gyroHandler = ^ (CMGyroData *gyroData, NSError *error) {
CMRotationRate rotate = gyroData.rotationRate;
NSLog(@"rotation rate = [%f, %f, %f]", rotate.x, rotate.y, rotate.z);
};
} else {
NSLog(@"No gyroscope on device.");
[motionManager release];
}
}
任何帮助和/或源代码,以简单地记录iPhone 4陀螺仪数据将不胜感激。非常感谢!