I tried to use videoOrientation(AVCaptureConnection) instead of the deprecated orientation(AVCaptureVideoPreviewLayer), but it did not rotate the video preview anymore.
I replaced this:
AVCaptureVideoPreviewLayer *previewLayer = ...;
previewLayer.orientation = AVCaptureVideoOrientationLandscapeRight;
With this:
AVCaptureVideoPreviewLayer *previewLayer = ...;
previewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
But it did not rotate the video preview. The problem was that I added and modified the AVCaptureVideoPreviewLayer before I added the AVCaptureDeviceInput to my AVCaptureSession. Therefore the connection of my AVCaptureVideoPreviewLayer was null. The solution was to add the AVCaptureVideoPreviewLayer after I added the AVCaptureDeviceInput to my AVCaptureSession.