Solution to the black screen when iOS development calls the camera (reason: no camera access)
In the development process calls the system camera, but the page appears black screen, the reason is that only part of the camera permission to judge not according to the version of the system,
if ([[[[Uidevice Currentdevice] systemversion] floatvalue] >= 7.0) {Avauthorizationstatus Authstatus = [Avcapturedevice Authorizationstatusformediatype:avmediatypevideo]; if (authstatus = = Avauthorizationstatusdenied | | authstatus = = avauthorizationstatusrestricted) {UIAler Tcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "Turn on camera Permissions" Message:nil Preferredstyle: Uialertcontrollerstylealert]; Uialertaction *okaction = [Uialertaction actionwithtitle:@ "Go to set" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {nsurl * url = [Nsurl urlwithstring:uiapplicationopensettingsurlstring]; if ([[[UIApplication sharedapplication] canopenurl:url]) {[UIApplication Sharedapplicati On] openurl:url]; } }]; Uialertaction *canleaction = [uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel Handler:nil]; [Alert addaction:okaction]; [Alert addaction:canleaction]; [Self Presentviewcontroller:alert animated:yes completion:nil]; Return }}else{Alauthorizationstatus author = [Alassetslibrary authorizationstatus]; if (author = = Kclauthorizationstatusrestricted | | author = = kclauthorizationstatusdenied) {uialertcontr Oller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "Turn on camera Permissions" Message:nil Preferredstyle: Uialertcontrollerstylealert]; Uialertaction *okaction = [Uialertaction actionwithtitle:@ "Go to set" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {nsurl * url = [Nsurl urlwithstring:uiapplicationopensettingsurlstring]; if ([[[UIApplication sharedapplication] canopenurl:url]) {[UIApplication Sharedapplicati On] openurl:url]; } }]; Uialertaction *canleaction = [Uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel Handler:nil]; [Alert addaction:okaction]; [Alert addaction:canleaction]; [Self Presentviewcontroller:alert animated:yes completion:nil]; Return } }
Solution to the black screen when iOS development calls the camera (reason: no camera access)