Ios detects the status of the camera, compass, recording, and gyroscope of the device.

Source: Internet
Author: User
// Check the front and rear cameras BOOL cameraAvailable = [UIImagePickerController isCameraDeviceAvailable: enabled]; // The Front BOOL frontCameraAvailable = [UIImagePickerController enabled: enabled]; // The back // check the CoreLocation. framework <CoreLocation/CoreLocation. h> BOOL magnetometerAvailbale = [CLLocationManager headingAvailable]; // check that the sound supports AVFoundation. framew Ork <AVFoundation/AVFoundation. h> AVAudioSession * audioSession = [AVAudioSession sharedInstance]; // returns an AVAudioSession instance BOOL audioAvailable = audioSession. inputAvailable; // bool value. Obtain whether the video is supported // check whether the video supports MobileCoreServices. framework <MobileCoreServices/MobileCoreServices. h>-(BOOL) isvideoCameraAvailable {// check all available media resource types, and then check the returned array. If the returned array contains the NSString object of the kUTTypeMovie type, this proves that the camera supports video recording: UIImagePickerController * picker = [[UIImagePickerController alloc] init]; NSArray * sourceTypes = [UIImagePickerController availableMediaTypesForSourceType: picker. sourceType]; // return the supported media type array [picker release]; I F (! [SourceTypes containsObject :( NSString *) kUTTypeMovie]) {// containsObject determines whether the array contains the following object return NO;} return YES;} // check whether CoreMotion is available for gyroscope. framework <CoreMotion/CoreMotion. h>-(BOOL) isGyroscopeAvailable {# ifdef _ IPHONE_4_0 // CMMotionManager * motionManager = [[CMMotionManager alloc] init]; BOOL gyroscopeAvailable = motionManager. gyroAvailable; [motionManager release]; return gyroscopeAvailable; # else return NO; # endif}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.