ios - 无法转换类型 'UITabBarController' Swift 的值

标签 ios swift uitabbarcontroller tabbar

我知道有人问过与我相同的问题,但实际上我确实尝试了建议但一无所获,所以我想看看是否有人可以根据我的代码解决这个问题。

我有一个称为 WelcomeVC 的 LoginViewController,因为我有一个按钮可以让用户登录应用程序,一旦他们登录,如果一切正常,它会加载 TabBarVC,它有 5 个 UIViewControllers 通过关系连接到它 ' viewcontrollers' 然而,这在 20 分钟前工作正常,但由于某种原因,当我去模拟器上测试它以向客户端显示它似乎在尝试登录时崩溃。

我的代码如下:

@IBAction func signUserIn(sender: AnyObject) {

    FIRAuth.auth()?.signInWithEmail(usernameTF.text!, password: passwordTF.text!, completion: { (user, error) in
        if error != nil
        {
            print("email/pass is wrong!")
        }
        else
        {
                let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
                let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("tBVC") as! TabBarVC
                self.presentViewController(nextViewController, animated:true, completion:nil)
        }

    })
}

这之前工作正常并以编程方式加载下一个 View ,而不是通过任何 segue。关于它为什么突然停止工作的任何建议以及关于如何修复它的任何想法?

这是错误代码:

Could not cast value of type 'UITabBarController' (0x1119548b0) to 'LT_Apps.TabBarVC' (0x10e4e9980).
(lldb) 

最佳答案

您没有设置 UITabBarController 类。像这样: enter image description here

更新:
1.TabBarVC类是否存在?
2.TabBarVC是否继承了UITabBarController
如果两者都是,只需复制粘贴 TabBarVC 到它的类项。并构建它!

关于ios - 无法转换类型 'UITabBarController' Swift 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38364323/

相关文章:

iOS 10 如何使用 UNUserNotificationCenter 查看待处理通知列表?

ios - 推送到下一个vc。 wkWebView

ios - UITabbarController - 如何取消选择 iOS 5.0 和 iOS 4.3 中的所有选项卡

ios - 如何将标签栏 Controller 作为 subview 添加到父 View ?

ios - 具有自动布局的全屏 UICollectionViewCell

ios - 应用程序图标未显示在 iTunes Connect 中

ios - 未加载 InHouse/Enterprise 应用程序的 Cocoa Touch 框架

ios - 隐藏 UIStackview 的 subview 时自动布局冲突

ios - 调用中的 Alamofire 额外参数 'method'

ios - 无法使用 TabBar 委托(delegate)方法