8

このエラーが発生していますが、修正方法がわかりません..

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

しかし、リンゴのドキュメントを見ると、それはMac OSの機能であると書かれています..IOSではありません...だから私は少し混乱しています...いくつかの答えを楽しみにしています..ありがとう..

4

3 に答える 3

26

6.0 より前のバージョンでも動作するサンプル コード:

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];
    }                
}
于 2012-10-01T16:15:06.080 に答える
3

AVCaptureConnectionは、iOSでも利用できます。あなたはおそらく間違ったドキュメントを見ました。

于 2012-07-17T23:41:54.477 に答える
1

上記の回答のサンプル コードは正常に動作します。しかし、自己を置き換える必要があります。AVCaptureVideoOrientation を使用した interfaceOrientation。

以下のようにコードを編集しました。

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

要件に応じて、向きは縦または横になります。

編集と提案を歓迎します。

于 2015-02-06T10:39:31.847 に答える