TabbarController打开CameraController(BarCodeScanner)时没有隐藏

问题描述 投票:0回答:1

我有一个BarCodeScanner-viewController,可以从3个不同的视图调用它。我的应用程序还具有一个tabbarController。问题是,选项卡栏在其中两个viewController中隐藏,而第三个则始终显示tabbarController,而在cameraMode(barCodeScanner)中。

我已经尝试在viewDidLoad(),viewDidAppear()和viewWillAppear()中都设置了“ self.tabBarController?.tabBar.isHidden = true”,并在viewWillDisappear()上将其更改为false)>

我还测试过将'scanner.hidesBottomBarWhenPushed = true'设置为无结果。

// 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
        }

我也不会在第三个示例中隐藏该标签栏。

我有一个BarCodeScanner-viewController,可以从3个不同的视图调用它。我的应用程序还具有一个tabbarController。问题是,选项卡栏从两个viewController中隐藏,而第三个总是......>

swift uitabbarcontroller barcode-scanner
1个回答
0
投票

使用Push实际上在navigationController中添加了一个新的控制器,这就是为什么您的选项卡不隐藏而无法用新的控制器覆盖来隐藏它,而您需要在Thrid示例中使用当前功能来更改push

替换

self.navigationController?.pushViewController(scanner, animated: true)
© www.soinside.com 2019 - 2024. All rights reserved.