This the first time i am working with the camera.Let me explain me about my App.It consists of a record button when user clicks on the record button,it opens the camera and asks the user to give permission to access the camera and microphone.So if user clicks on "dont allow" button when asked for camera or microphone or access photos,can i open the camera although he clicked on "dont allow" button.Below is the code that i am using to open camera
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// alert the user that the camera can't be accessed
UIAlertView *noCameraAlert = [[UIAlertView alloc] initWithTitle:@"No Camera" message:@"Unable to access the camera!" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[noCameraAlert show];
} else {
imagePickerCustom = [[UIImagePickerController alloc] init];
imagePickerCustom.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerCustom.delegate = self;
imagePickerCustom.allowsEditing = NO;
imagePickerCustom.showsCameraControls = NO;
imagePickerCustom.cameraDevice = UIImagePickerControllerCameraDeviceFront;
imagePickerCustom.videoMaximumDuration = 61;
imagePickerCustom.videoQuality = UIImagePickerControllerQualityTypeMedium;
imagePickerCustom.navigationBarHidden = YES;
imagePickerCustom.toolbarHidden = YES;
imagePickerCustom.wantsFullScreenLayout = YES;
//add tap gesture on camera
// UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self
// action:@selector(handleSingleTap:)];
imagePickerCustom.wantsFullScreenLayout = YES;
//to get camera full screen
imagePickerCustom.cameraViewTransform = CGAffineTransformScale(imagePickerCustom.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);
imagePickerCustom.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
imagePickerCustom.videoQuality = UIImagePickerControllerQualityTypeMedium;
NSArray *sourceTypes =
[UIImagePickerController availableMediaTypesForSourceType:imagePickerCustom.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
NSLog(@"Can't save videos");
}
else if{
NSLog(@"open camera overlayview");
}
I know some code which detects the user access to camera
ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];
[lib enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSLog(@"%i",[group numberOfAssets]);
} failureBlock:^(NSError *error) {
if (error.code == ALAssetsLibraryAccessUserDeniedError) {
NSLog(@"user denied access, code: %i",error.code);
}else{
NSLog(@"Other error code: %i",error.code);
}
}];
Is it necessary for me to close the camera if user taps on "dont allow" button when prompted for using camera or microphone.If clicked on "dont allow" can i open the camera.I dont want to access any gallery videos.User just records the video and uploads to a server.
Thanks in Advance....
0 comments:
Post a Comment