Skip to content
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

Adding option to not print comments from the library and add support for orientation changes #2

Open
Idomo opened this issue Jun 30, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@Idomo
Copy link
Contributor

Idomo commented Jun 30, 2018

Hi,
I'd like to suggest you to give the developer an option to not show all the library comments, at some point it's starts to be annoying and the prints that I wort just swallowed into the library's prints.

The second thing is to add support for orientation changes, on portrait everything looks good, but on landscape the camera is not rotating and things not looks very good.
I'v actually added some support by myself, but I'm sure you can do it better because you build this library.

Here is what I added/changed:

CameraViewController.swift

public var videoOrientation: AVCaptureVideoOrientation = .portrait

open override func viewDidLoad() {
	super.viewDidLoad()
	...
	previewLayer.connection?.videoOrientation = videoOrientation
	...
}

open override func viewDidLayoutSubviews() {
	super.viewDidLayoutSubviews()
	...
	previewLayer?.connection?.videoOrientation = videoOrientation
}

ScannerController.swift

func checkOrientation() -> AVCaptureVideoOrientation{
	switch UIDevice.current.orientation {
        case .landscapeLeft:
            	return .landscapeRight
	case .portrait:
		return .portrait
	case .portraitUpsideDown:
		return .portraitUpsideDown
	case .landscapeRight:
		return .landscapeLeft
	default:
		return .portrait
	}
}

override func viewDidLoad() {
	...
	videoOrientation = checkOrientation()
	...
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
	super.viewWillTransition(to: size, with: coordinator)
        
	videoOrientation = checkOrientation()
}

Thanks,
Ido.

@jonasbeckers jonasbeckers added the enhancement New feature or request label Jul 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants