Search code examples
iosswiftuinavigationcontrolleravcapturesession

Navigation bar and AVCaptureSession


I have a View controller with AVCaptureSession to scan barcode. I picked code here. I added navigation bar to it. But time, battery life, etc. didn't show.

enter image description here

enter image description here

I tried with UINavigation controller and NavigationBar widget.


Solution

  • You're most likely not showing the UIStatusBar, try adding this to your ViewController:

    override func prefersStatusBarHidden() -> Bool {
        return false
    }
    
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .Default
    }
    

    Another option is setting values for status bar attributes in your main property list file:

    UIStatusBar attributes in .plist

    Status bar style defines the style of your status bar, see UIStatusBarStyle for what option you have.

    View controller-based status bar appearance defines whether you want to have different styles for each view controller or one style for all view controllers.