Never called deinit method in CameraEngine
Closed this issue · 1 comments
alexanderkhitev commented
Hello! Thanks for this framework!
I was faced with the fact that deinit method is not called in CameraEngine, please tell me how to fix it?
alexanderkhitev commented
This problem in the CameraEngine handleDeviceOrientation. I changed this functions and solved this problem
private func handleDeviceOrientation() {
if self.rotationCamera {
if (!UIDevice.current.isGeneratingDeviceOrientationNotifications) {
UIDevice.current.beginGeneratingDeviceOrientationNotifications()
}
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIDeviceOrientationDidChange, object: nil, queue: OperationQueue.main) { [weak self] (_) -> Void in
guard self != nil else { return }
if self!.rotationCamera {
let orientation = AVCaptureVideoOrientation.orientationFromUIDeviceOrientation(UIDevice.current.orientation)
if orientation == .portraitUpsideDown {
return
}
self!.previewLayer.connection?.videoOrientation = AVCaptureVideoOrientation.orientationFromUIDeviceOrientation(UIDevice.current.orientation)
}
}
}
else {
if (UIDevice.current.isGeneratingDeviceOrientationNotifications) {
UIDevice.current.endGeneratingDeviceOrientationNotifications()
}
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
}
}