【发布时间】:2011-03-14 20:18:14
【问题描述】:
我试图简单地 NSLog 新 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 陀螺仪数据的帮助和/或源代码将不胜感激。非常感谢!
【问题讨论】:
-
这是一个不影响应用程序运行的bug。
-
iOS 4.2 发布后,错误信息消失。我想我们可以关闭它。
-
我在尝试记录“态度”时遇到同样的错误,但该错误似乎不会导致真正的问题:NSLog 有效。
标签: iphone objective-c