Contents

조회 수 1948 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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
번호 분류 제목 글쓴이 날짜 조회 수
313 Develop [c] 최대공약수 알고리즘 (유클릿) hooni 2003.04.23 8900
312 Develop [js] 밀리터리 프로그램(전역일 계산) 7 file hooni 2013.04.23 8923
311 Develop [c++] 바탕화면 테두리에 자석처럼 붙는 스냅효과.. file hooni 2013.04.23 8923
310 Develop [c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현 file hooni 2013.04.23 8975
309 Develop [js] 객체 머지.. hooni 2013.12.17 8989
308 Develop [c] OpenGL 직사각형(2D) 크기 확대/축소 hooni 2003.04.23 9088
307 Develop [c] 간단한 채팅(클라이언트/서버) 프로그램 소스 file hooni 2003.04.23 9091
306 Develop [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ file hooni 2013.04.23 9120
305 Develop [c++] mfc 윈도우에서 ODBC 사용하여 MDB파일 읽기.. ㅋㅋ file hooni 2013.04.23 9136
304 Develop 다운 받아서 테스트 해볼것.. hooni 2013.04.23 9161
303 Develop [c] 하노이탑 - 재귀함수 hooni 2003.04.23 9169
302 Develop [php] URL/URI 관련 환경변수 hooni 2003.04.23 9211
Board Pagination Prev 1 ... 40 41 42 43 44 45 46 47 48 49 ... 71 Next
/ 71