Я пробую только к NSLog вывод нового iPhone 4 Gyroscope. Но после чтения документации и после их примера кода я получаю эту ошибку.
ERROR,Time,300635803.946,Function,"CLLoggingSetFile",could not open locations log /var/mobile/Library/Caches/CoreMotion/CoreMotion.log
Даже если я просто устанавливаю свой объект motionManager с [[выделение CMMotionManager] init]; самостоятельно и никакой другой код, я все еще получаю ошибку.
Вот мой.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 очень ценились бы.Большое спасибо!
Попробуйте это,
motionManager.gyroUpdateInterval = 1.0/60.0;
[motionManager startGyroUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMGyroData *gyroData, NSError *error)
{
CMRotationRate rotate = gyroData.rotationRate;
NSLog(@"rotation rate = [%f, %f, %f]", rotate.x, rotate.y, rotate.z);
}];