if ([[[[Uidevice Currentdevice] systemversion] floatvalue] >= 7.0) {
Check whether the permission open for user in Settings
Avauthorizationstatus authstatus = [Avcapturedevice authorizationstatusformediatype:avmediatypevideo];
if (authstatus = = Avauthorizationstatusrestricted | | authstatus = = avauthorizationstatusdenied)
{
Cmalertview *alert = [[Cmalertview alloc]init];
[Alert Setalertviewframewithx:self.localview.frame.size.width/8 WITHY:SELF.LOCALVIEW.BOUNDS.SIZE.HEIGHT/2 WithW: SELF.LOCALVIEW.FRAME.SIZE.WIDTH-SELF.LOCALVIEW.FRAME.SIZE.WIDTH/4 withh:100];
[Alert setimage:@ "[email protected]" withorignalx:20 withy:30 withw:30 withh:30];
[Alert setlabelwithtext:nslocalizedstringfromtable (@ "alert_view_please_open_camera_visit_permission", @ " StringInfo ", nil) withx:50 withy:15 withw:180 withh:50];
[Alert Setfont:[uifont systemfontofsize:18.0f] Withcolor:[uicolor Whitecolor]];
[Alert Setalertviewbackgroundcolor:[uicolor colorwithred:68/255.0f green:153/255.0f blue:181/255.0f alpha:1.0]];
[Alert setalertviewdisplaytype:@ "Info"];
[Alert show];
[Alert release];
}
else{
Present the camera view
Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc] Init];//initial
Self.imagepickercontroller = Picker;
[Picker release];
Self.imagePickerController.delegate = self;
self.imagePickerController.allowsEditing = Yes;//set Editable
if ([Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {
Self.imagePickerController.sourceType = Uiimagepickercontrollersourcetypecamera;
}else{
Self.imagePickerController.sourceType = uiimagepickercontrollersourcetypephotolibrary;
}
[Self presentViewController:self.imagePickerController animated:yes completion:nil];//enter camera
}