0
這在我第一次與camera.Let工作我解釋一下我關於我的App.It由一個錄音按鈕的時候按鈕時,在錄製按鈕用戶點擊,它會打開相機並要求用戶授予訪問相機和麥克風的權限。因此,如果用戶在詢問相機或麥克風或訪問照片時是否單擊「不允許」按鈕,是否可以打開相機,雖然他點擊了「dont讓」 button.Below是我使用打開相機訪問攝像機,如果用戶點擊「允許不」打開相機
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");
}
我知道一些代碼,檢測到攝像機的用戶訪問代碼
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);
}
}];
如果用戶在提示使用相機或麥克風時點擊「不允許」按鈕,是否需要關閉相機?如果點擊「不允許」,我可以打開相機嗎?我不想訪問任何圖庫用戶只需記錄視頻並上傳到服務器。
在此先感謝....