Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You want to find out whether the current iOS device that is running your program has gyroscope hardware available.
Use the isGyroAvailable
method of an instance of CMMotionManager to detect the gyroscope hardware. The isGyroActive method
is also available if you want to detect whether the gyroscope hardware
is currently sending updates to your program (in other words, whether
it is active):
- (BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
CMMotionManager *motionManager = [[CMMotionManager alloc] init];
if ([motionManager isGyroAvailable]){
NSLog(@"Gryro is available.");
} else {
NSLog(@"Gyro is not available.");
}
if ([motionManager isGyroActive]){
NSLog(@"Gryo is active.");
} else {
NSLog(@"Gryo is not active.");
}
self.window = [[UIWindow alloc] initWithFrame:
[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}