2012-07-17 27 views
8

Tôi nhận lỗi này và tôi không có ý tưởng làm thế nào để sửa chữa nó ..isOrientationSupported bị phản đối trong IOS

WARNING: -[<AVCaptureVideoPreviewLayer: 0xad482c0> isOrientationSupported] is deprecated. Please use AVCaptureConnection's -isVideoOrientationSupported 

tuy nhiên khi tôi nhìn vào những quả táo documentation nó nói rằng nó là một chức năng Mac OS .. không IOS ... vì vậy tôi hơi bối rối ... mong nhận được một số câu trả lời .. Cảm ơn ..

Trả lời

3

AVCaptureConnection cũng có sẵn cho iOS here. Có thể bạn đã xem sai tài liệu.

26

Một số mẫu mã mà hoạt động trên trước 6.0 cũng như:

if ([captureVideoPreviewLayer respondsToSelector:@selector(connection)]) 
{ 
    if ([captureVideoPreviewLayer.connection isVideoOrientationSupported]) 
    { 
     [captureVideoPreviewLayer.connection setVideoOrientation:self.interfaceOrientation]; 
    } 
} 
else 
{ 
    // Deprecated in 6.0; here for backward compatibility 
    if ([captureVideoPreviewLayer isOrientationSupported]) 
    { 
     [captureVideoPreviewLayer setOrientation:self.interfaceOrientation]; 
    }     
} 
+0

Cảm ơn! Đó là những gì tôi đang tìm kiếm! –

+0

Thay vì: self.interfaceOrientation là UIInterfaceOrientation, bạn nên sử dụng AVCaptureVideoOrientation. – Despotovic

1

Trên đây đã trả lời mẫu mã hoạt động tốt. Nhưng cần phải tự thay thế. interfaceOrientation với AVCaptureVideoOrientation.

Mã đã chỉnh sửa như sau.

if ([captureVideoPreviewLayer.connection isVideoOrientationSupported]) 
{ 
    [captureVideoPreviewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait]; 
} 

Tùy thuộc vào yêu cầu định hướng sẽ là chân dung hoặc phong cảnh.

Chỉnh sửa và đề xuất được hoan nghênh.

Các vấn đề liên quan