Tôi đang cố gắng đơn giản là NSLog đầu ra của Con quay hồi chuyển iPhone 4 mới. Nhưng sau khi đọc tài liệu và theo mẫu mã của họ, tôi nhận được lỗi này.CMMotionManager và Con quay hồi chuyển trên iPhone 4
ERROR,Time,300635803.946,Function,"CLLoggingSetFile",could not open locations log /var/mobile/Library/Caches/CoreMotion/CoreMotion.log
Ngay cả khi tôi chỉ thiết lập đối tượng MotionManager với [[CMMotionManager alloc] init]; một mình và không có mã nào khác, tôi vẫn gặp lỗi.
Đây là tệp .h của tôi.
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
@interface GyroTest0ViewController : UIViewController {
CMMotionManager *motionManager;
NSOperationQueue *opQ;
}
@end
Và đây là tệp .m của tôi.
- (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];
}
}
Mọi trợ giúp và/hoặc mã nguồn chỉ cần ghi dữ liệu con quay hồi chuyển iPhone 4 sẽ được đánh giá cao. Cảm ơn nhiều!
Lỗi của nó không ảnh hưởng đến hoạt động của ứng dụng. – twerdster
Sau khi iOS 4.2 ra khỏi thông báo lỗi biến mất. Tôi nghĩ chúng ta có thể đóng cái này. – Kay
Tôi nhận được lỗi tương tự khi tôi cố gắng đăng nhập 'thái độ', nhưng lỗi này dường như không gây ra vấn đề thực sự: NSLog hoạt động. – RawMean