How to use the iOS system camera gracefully

Source: Internet
Author: User

NSString *mediatype = Avmediatypevideo; Or avmediatypeaudioavauthorizationstatus authstatus = [Avcapturedevice Authorizationstatusformediatype:mediatype] ;//This status was normally not Visible-the Avcapturedevice class methods for discovering devices does not return devices th E user is restricted from accessing.if (authstatus = = avauthorizationstatusrestricted) {NSLog (@ "restricted");} The user has explicitly denied permission for media capture.else if (authstatus = = avauthorizationstatusdenied) {Nslo G (@ "Denied");} The user has explicitly granted permission for media capture, or explicit user permission are not necessary for the Medi A type in Question.else if (authstatus = = avauthorizationstatusauthorized) {NSLog (@ "Authorized");}  EXPLICIT user permission is required for media capture, but the user have not yet granted or denied such permission.else if (Authstatus = = avauthorizationstatusnotdetermined) {[Avcapturedevice Requestaccessformediatype:mediatype completionhandler:^(BOOL granted)        {//Make sure we execute our code on the main thread so we can update the UI immediately. See documentation for Abaddressbookrequestaccesswithcompletion where it says//"The completion handle        R is called in an arbitrary queue. " Though there is no similar mention for Requestaccessformediatype, it appears it does//the same thing        .                Dispatch_async (Dispatch_get_main_queue (), ^{if (granted) {//UI updates as needed            NSLog (@ "Granted access to%@", mediatype);            } else {//UI updates as needed NSLog (@ "Not granted access to%@", mediatype);    }        }); }];} else {NSLog (@ "Unknown authorization Status");}

How to use the iOS system camera gracefully

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.