| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The AVCaptureVideoPreviewLayer connection orientation is never synced with the device orientation, causing the camera preview to appear rotated 90 degrees when the device is in landscape mode (e.g. iPad). Add _syncPreviewOrientation() which reads the current interface orientation from UIWindowScene and applies it to the preview layer connection using videoRotationAngle (iOS 17+) or the deprecated videoOrientation fallback. The sync is called on load, on orientation change, and after toggleCamera().
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Gary Faulkner.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Problem
The AVCaptureVideoPreviewLayer connection orientation is never synced with the current device orientation. This causes the camera preview to appear rotated 90 degrees when the device is in landscape mode - most commonly observed on iPad, but affects any iOS device that supports multiple orientations.
Root Cause
In index.ios.ts, createNativeView() creates the AVCaptureVideoPreviewLayer from the capture session and adds it to the view, but never sets videoOrientation (or videoRotationAngle on iOS 17+) on the layer connection. The onLayout() method updates the layer frame but not its orientation.
Fix
Added a private _syncPreviewOrientation() method that:
The method is called:
Testing
Verified the fix corrects the 90-degree rotation on iPad in landscape mode when using MLKitView with DetectionType.Barcode via @nativescript/mlkit-barcode-scanning.
Made with Cursor