1

I have problem to display my ViewControllers. Sometimes happens this... freezing UI while pushing new ViewController. All UI elements created programmatically with SnapKit (in current code CameraUI class).

GIF demo: https://radikal.ru/video/VeDy5trCfNn

Pushing Action from origin ViewController

@objc func cameraAction(){
        let cameraVC = CameraViewController()
        self.navigationController?.pushViewController(cameraVC, animated: true)
    }

CameraViewController

class CameraViewController: UIViewController{
lazy var UI = CameraUI(view: self.view, navController: self.navigationController!)
override func viewDidLoad() {
        super.viewDidLoad()

        title = "Camera"
        addUIElements()
        setupCaptureSession()
        setupDevice()
        setupInputOutput()
        setupPreviewLayer()
        startRunningCaptureSession()
        addActions()
    }
private func addUIElements(){
        UI.addElementsToSuperView()
        view.layoutIfNeeded()
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
George Heints
  • 1,303
  • 3
  • 20
  • 37

1 Answers1

1

You did not provide a lot of code, but I would venture to suggest that the problem is that you call methods that inhibit the appearance of the screen.

You should try to move some methods for camera setup to viewWillApear or viewDidAppear.

Look at this methods:

        setupCaptureSession()
        setupDevice()
        setupInputOutput()
        setupPreviewLayer()
        startRunningCaptureSession()
Vlad Krupenko
  • 361
  • 2
  • 9