ios - 覆盖 TabBarController 中 ViewController 的类型?

标签 ios swift uikit uitabbarcontroller

我正在尝试以 viewControllers 方式覆盖类型。

override var viewControllers : [BaseViewController]? {
    get {
        return self.viewControllers
    }
}

但是我得到了这个错误。

Property 'viewControllers' with type '[BaseViewController]?' cannot override a property with type '[UIViewController]?'

这能做到吗?

最佳答案

您可以通过创建新属性来解决它。比如这个。

var baseViewControllers: [BaseViewController]? {
      return self.viewControllers as? [BaseViewController] 
}

关于ios - 覆盖 TabBarController 中 ViewController 的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35718428/

相关文章:

ios - 不能使用可重复使用的电池。如何优化 tableView 中的平滑滚动?

ios - 为什么 Today Notification Widget 在启动时崩溃?

objective-c - UILabel 中的换行符?

ios - 自定义 UIBarButtonItem 和界面旋转

ios - 插件工具包 : -[PKService run] iOS Keyboard extension error

ios - 在 iOS 中使用 GMSAutocompleteFetcherDelegate 时如何查找经纬度

Swift 获取自定义注解信息

ios - Collection View 显示滚动时选择的尚未选择的单元格

iphone - 用于在恒定时间内跟踪 UITableView 行与基础数据的对应关系的设计模式

swift - 带有 SwiftUI View 的 UIKit TabBar