-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: Camera video preview layer should not rotate with orientation change #7
Comments
Hey @gitmh, thanks for the report! That's something I've not considered. Does the rotation matter when scanning QR codes? (Does it scan differently?) How do you think the plugin should handle device orientation? |
I have a cordova app which is fixed to landscape only. The scanning also works without rotation but it is very annoying to "find" the code if you move left and the preview moves right and vice versa because the video preview is rotated 180° on your screen (up is down and down is up). I'm not very familiar with Swift so I tried to fix this by adding something like this:
I managed to solve the issue with a NSTimer calling an additional function adjustCameraOrientation. It also needs to resize the frame of the UIView and the previewLayer to work properly on rotation. My current code is here: https://www.dropbox.com/s/ll24xadtgrpbolb/QRScanner.swift?dl=0 Maybe a timer is not a proper solution for this problem, sorry I never used Swift before. |
Still looking at this – I added some device orientation controls to the manual tests to help with testing for this issue: d9a11cd#diff-2a8a5fef3397df87ab538f028a5c6b50R96 I'm not very familiar with iOS's layout system – I think the best solution is to disable orientation changes on just the video preview layer (such that the camera always stays oriented with the screen as the device is rotated). I've not been able to get a working solution yet – pull requests welcome! |
@bitjson I also very unfamiliar with this orientation stuff. The solution I mentioned in the dropbox link with a timer works very well in my app. The problem is that I was unable to register a proper event handler for the orientation change. |
When you have a landscape cordova app and start scanning the camera is not rotated correctly. The AVCaptureVideoOrientation should change with rotating the device.
The text was updated successfully, but these errors were encountered: