Comments (5)
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?
from cordova-plugin-qrscanner.
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:
let app = UIApplication.sharedApplication()
switch app.statusBarOrientation {
case .Portrait:
captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.Portrait;
case .PortraitUpsideDown:
captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.PortraitUpsideDown;
case .LandscapeLeft:
captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeLeft;
case .LandscapeRight:
captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight;
default:
captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight;
}
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.
from cordova-plugin-qrscanner.
Hey @gitmh, thanks again for the report. Just wanted to let you know that I'm currently finishing up with the browser implementation (#6), but this is on my radar. I plan to take a swing at this issue once the initial browser implementation is merged.
from cordova-plugin-qrscanner.
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!
from cordova-plugin-qrscanner.
@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.
from cordova-plugin-qrscanner.
Related Issues (20)
- Browser Plugin Not Working
- camera preview wont work anymore
- Limit qr scan area? HOT 3
- Camera preview has a gray layer HOT 1
- .scan didn't work HOT 1
- Support continuous scanning
- Can't compile Android app when targeting SDK version 31 HOT 2
- Who has the best Fork ? HOT 4
- Cant show QRScanner camera view in ionic
- .scan() doesn't work after migrating to Cordova-Android 11
- Live QR Codes HOT 3
- Build failed in IOS HOT 3
- Android Cordova 11 build fails HOT 2
- iPhone 14 Can't focus HOT 2
- 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString' HOT 1
- Could not find method compile() for arguments [com.journeyapps:zxing-android-embedded:3.3.0]
- Small QR codes
- Does it supports an external USB camera?
- BSF Cordova Ecosystem Crowdfunding Plan
- Access denied finding property "vendor.camera.aux.packagelist"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-qrscanner.