无法将类型“(SwipeableTabBarController).Type”的值转换为预期的参数类型 'UIView'

Cannot convert value of type '(SwipeableTabBarController).Type' to expected argument type 'UIView'

我想将 Tabbar 添加到我的应用程序中。但是当我尝试添加它时,它在 header 中给出了错误。如何开启Tabbar功能?

public extension UIViewController { 
    public func setTabBarSwipe(enabled: Bool) {
        if let swipeTabBarController = tabBarController as? SwipeableTabBarController {
            swipeTabBarController.isSwipeEnabled = enabled
        }
    }
}

class MainTableViewController: UITableViewController {
override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(SwipeableTabBarController)
}

如果您的 tabBarController 是应用程序的根视图控制器,请使用它。

        if let window = UIApplication.shared.keyWindow, 
           let tabBar = window.rootViewController as? SwipeableTabBarController {                 
             tabBar.isSwipeEnabled = enabled
        }

您不能在此处添加用户定义类型 SwipeableTabBarController 选项卡作为子视图

 view.addSubview(SwipeableTabBarController)

您需要添加一个实例,例如

 let vc = SwipeableTabBarController()
 self.addChild(vc)
 vc.view.frame = self.view.bounds
 view.addSubview(vc.view)
 vc.willMove(toParent:self)