Views 1873 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

iOS 앱에서 최초 카메라를 사용할건지 물어 볼 때 사용자가 쓰지 않는다고 하면 ㅡ,.ㅡ;;

나중에 카메라에서 검은 화면이 뜨게 됨 ㅋㅋ

카메라를 안 쓴다고 했으면 쓰지 말던지, 필요하면 다시 설정해라! 라고 알려줄 필요가 있음.

이 부분을 위한 설정 값을 읽어와서 분기처리 하는 샘플 코드~


/*
// Media types
AVF_EXPORT NSString *const AVMediaTypeVideo    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeAudio    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeText    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeClosedCaption    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeSubtitle    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeTimecode    NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVMediaTypeMetadata    NS_AVAILABLE(10_8, 6_0);
AVF_EXPORT NSString *const AVMediaTypeMuxed    NS_AVAILABLE(10_7, 4_0);
*/

AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(status == AVAuthorizationStatusAuthorized)
{
    // authorized
    NSLog(@"authorized");
}
else if(status == AVAuthorizationStatusDenied)
{
    // denied
    NSLog(@"denied");
}
else if(status == AVAuthorizationStatusRestricted)
{
    // restricted
    NSLog(@"restricted");
}
else if(status == AVAuthorizationStatusNotDetermined)
{
    // not determined
    NSLog(@"not determined");
    
    [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
        if(granted){ // Access has been granted ..do something
                
        } else { // Access denied ..do something
                
        }
    }];
}

[참조] https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVCaptureDevice_Class/index.html

[참조] https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVFoundation_Constants/index.html

[출처] http://stackoverflow.com/questions/20464631/detect-permission-of-camera-on-ios

?

List of Articles
No. Category Subject Author Date Views
665 Develop [ios] @property의 속성 (strong, weak, copy) 사용 경우 hooni 2014.08.08 1659
664 Develop [ios] TextField 특정 문자만 사용하도록 하기 hooni 2014.06.30 2678
663 Develop [ios] XCode에서 Provisioning Profile 여러개 중복될 때 hooni 2014.06.26 2817
662 Develop 알고리즘 성능 분석 기준 hooni 2014.06.24 2786
661 Develop 알고리즘 성능분석 file hooni 2014.06.24 2966
660 Develop [ios] iOS에서 디바이스 종류 알아오기 hooni 2014.05.24 3648
659 Develop [ios] 아이폰 GPS 사용하기 hooni 2014.05.24 3954
658 Develop [ios] 언어, 지역, 국가 설정 가져오기 hooni 2014.05.12 269854
657 Develop [ios] URL 파라미터 파싱~ hooni 2014.05.12 3674
656 Develop [ios] 앱 딜리게이트 얻어오기. (AppDelegate) hooni 2014.05.10 3343
655 Develop [ios] 앱딜리게이트 라이프사이클 (AppDelegate Lifecycle) file hooni 2014.05.09 4454
654 Develop [ios] 애플 앱스토어 IDFA 리뷰 정책 변경 안내 file hooni 2014.05.07 4182
653 Develop [ios] NSString URL Encode/Decode (인코딩/디코딩) hooni 2014.05.02 3417
652 Develop [ios] 커스텀 폰트 사용하기 (Custom Fonts) file hooni 2014.04.30 3135
651 Develop [ios] iOS 의 인앱구매 소개 file hooni 2014.04.29 3827
650 Develop [js] Array.splice() 설명 hooni 2014.04.24 3003
Board Pagination Prev 1 ... 10 11 12 13 14 ... 53 Next
/ 53