【问题标题】:Swift" Thread 1: Signal SIGABRT in PresentViewControllerSwift”线程 1:PresentViewController 中的信号 SIGABRT
【发布时间】:2016-10-28 02:29:15
【问题描述】:

我想知道为什么我在this video 中关注的代码不起作用。它总是不断抛出这个错误:

线程 1:信号 SIGABRT。

我是 Swift 和 iOS 开发的新手。

错误抛出:

self.presentViewController(homeViewController, animated: true, completion: nil)

代码:

FIRAuth.auth()?.addAuthStateDidChangeListener { auth, user in
          if let user = user {
            let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let homeViewController: UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("HomeView") 
            self.presentViewController(homeViewController, animated: true, completion: nil)
          } else {
            self.loginButton.center = self.view!.center
            self.loginButton.readPermissions = ["public_profile", "email", "user_friends"]
            self.loginButton.delegate = self
            self.view!.addSubview(self.loginButton)

            self.loginButton.hidden = false
          }
        }

【问题讨论】:

    标签: ios swift presentviewcontroller


    【解决方案1】:

    首先转到您的 main.storyboard 并检查您的故事板 segues 是否正确命名,应命名为“HomeView”。

    然后尝试清洁您的产品(SHIFT + CMD + A 或“产品 --> 清洁”)。

    希望这行得通。

    【讨论】:

    • 不工作,但我发现此错误消息Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "HomeView" from storyboard "Main", but didn't get a UITableView.'。这是什么意思?
    • 我拖动一个 UITableViewController 并使用它而不是 UIViewController 并且错误消失了,但我想知道为什么我不能使用 UIViewController?而且当我在可可中创建一个新文件时,触摸没有 UIViewController 选项。现在,我有一个问题,两者之间有什么区别。
    【解决方案2】:

    抱歉,我认为 Cocoa 触摸选项中缺少 UIViewController。所以,我通过将子类更改为 UIViewController 而不是 UITableViewController 来修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      相关资源
      最近更新 更多