Skip to content

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

@Idomo

Description

@Idomo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions