0
votes

I have a BarCodeScanner-viewController which I call from 3 different views. My app also has a tabbarController. Problem is, the tabbar hides from two of the viewControllers, while the third one always shows the tabbarController, while in cameraMode (barCodeScanner).

I've tried to set the ´self.tabBarController?.tabBar.isHidden = true´ in both viewDidLoad(), viewDidAppear() and viewWillAppear() and changed it to false on viewWillDisappear()

I have also tested to set 'scanner.hidesBottomBarWhenPushed = true' without result.

// working:
setUpBackButton(withTitle: NSLocalizedString("button_cancel", comment: ""))
        let scanner = BarCodeScanner()
        self.navigationController?.pushViewController(scanner, animated: true)
        scanner.callback = { result in
            // code with result
        }


// working: 
setUpBackButton()
        let scanner = BarCodeScanner()
        scanner.modalPresentationStyle = .overCurrentContext
        self.navigationController?.pushViewController(scanner, animated: true)
        scanner.callback = { result in
            // code with result
        }


// NOT WORKING (i.e. not hiding the tabbarController):
let scanner = BarCodeScanner()
        setupBackButton()
        scanner.modalPresentationStyle = .overCurrentContext
        self.navigationController?.pushViewController(scanner, animated: true)
        scanner.callback = { result in
            // code with result
        }

I wan't the tabbar to be hidden in the third example too.

1
instead of pushing, present scannerController - Abu Ul Hassan
@AbuUlHassan yeah that works, nice, thanks. Any idea why the first two work with push? - maniponken
in third you are using let scanner = BarCodeScanner() setupBackButton() scanner.modalPresentationStyle = .overCurrentContext self.navigationController?.pushViewController(scanner, animated: true) scanner.callback = { result in // code with result } here you are calling setupBackButton() this functiona contains same code so may be duplicate code causing the issue - Abu Ul Hassan
happy coding :) - Abu Ul Hassan
@AbuUlHassan If you add this as an answer I can accept it :) - maniponken

1 Answers

1
votes

Using Push actually adds a new controller in navigationController thats why your tabbar is not hiding to hide it with new controllers overlay you need to change push with present function in Thrid example

Replace

self.navigationController?.pushViewController(scanner, animated: true)

With

self.navigationController?.present(scanner, animated: true, completion: nil)