Open Vweston opened 3 years ago
@Vweston Same here. Did you ever find a solution for this?
I have the same issue. Here are the details:
pod init
and then configure Podfile
as per your instructionspod install
, when it's finished Podfile.lock
says that 5.1.3 was installed.info.plist
ViewController
add let cameraManager = CameraManager()
viewDidLoad()
add let cameraManager = CameraManager()
I'm running on two devices. An iPhone X with 14.4.2 and an iPad Mini (5th generation) also on 14.4.2. I get the same results on either device.
I notice that the default value in the source for shouldKeepViewAtOrientationChanges
is false. So I create a CameraManager subclass and override shouldKeepViewAtOrientationChanges
so it returns true. In ViewController
I change it to let cameraManager = MyCameraManager()
Then run:
I haven't found a solution for the orientation issues but viewWillTransition()
helped with the cropping.
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
cameraManager.addPreviewLayerToView(view)
}
I don't know if that's the best solution for that.
Can you provide any help on the orientation issues?
For my case, I setting like that
cameraManager.shouldKeepViewAtOrientationChanges = false
cameraManager.shouldRespondToOrientationChanges = true
And in where do the update UI when rotation change like viewWillTransition
for example (me is updateUIView
because I code SwiftUI), call resetOrientation
function
DispatchQueue.main.async {
self.cameraManager.resetOrientation()
}
qhu91it Thank you that solved my problem
I’m confused. I created a new project. Added Swift package to project. Added a cameraView & label to storyboard. Build & run on device (iPad Pro 10.5” - iPadOS 14) in Portrait. Everything looks great. Camera view is correct. Rotate left & image is now displaying 90 degrees right. Rotate device back to portrait & camera image now incorrect there as well.
if I start out in landscape right. Then cameraView is rotated 90 degrees right, but is correct when back in portrait. I can only get it to correctly view in portrait mode no matter what settings I try. See images where the “This is a Label is always correctly displayed above cameraView.
here is my ViewController // // ViewController.swift // BasicCameraManager // // Created by Vincent Weston on 1/20/21. //
import UIKit import CameraManager
class ViewController: UIViewController {
}
Start in Portrait
rotated
Started in landscapeRight
Rotated back to portrait
any help would be really great.👍