线程1:在模拟器上运行时,信号SIGABRT错误

时间:2020-01-23 09:33:28

标签: ios swift xcode11

我正在尝试创建一个Instagram克隆iOS应用,当打开当前程序的模拟器时,我的错误堆积如山,没有任何解释。

错误消息和零件

错误消息

Thread 1: signal SIGABRT

AppDelegate.swift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

ViewController.swift

import UIKit
import ESTabBarController

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    setupTab()
  }

  func setupTab() {

    // create ESTabBarController with image file
    let tabBarController: ESTabBarController! = ESTabBarController(tabIconNames: ["home", "camera", "setting"])

    // color settings
    tabBarController.selectedColor = UIColor(red: 1.0, green: 0.44, blue: 0.11, alpha: 1)
    tabBarController.buttonsBackgroundColor = UIColor(red: 0.96, green: 0.91, blue: 0.87, alpha: 1)
    tabBarController.selectionIndicatorHeight = 3

    // add ESTabBarController to parent ViewController(=self)
    addChild(tabBarController)
    let tabBarView = tabBarController.view!
    tabBarView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(tabBarView)
    let safeArea = view.safeAreaLayoutGuide
    NSLayoutConstraint.activate([
      tabBarView.topAnchor.constraint(equalTo: safeArea.topAnchor),
      tabBarView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor),
      tabBarView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor),
      tabBarView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor),
      ])
    tabBarController.didMove(toParent: self)

    // ViewController setting 
    let homeViewController = storyboard?.instantiateViewController(withIdentifier: "Home")
    let settingViewController = storyboard?.instantiateViewController(withIdentifier: "Setting")

    tabBarController.setView(homeViewController, at: 0)
    tabBarController.setView(settingViewController, at: 2)

    // use the center tub as a button 
    tabBarController.highlightButton(at: 1)
    tabBarController.setAction({
      // ImageViewController is shown once a button is pushed
      let imageViewController = self.storyboard?.instantiateViewController(withIdentifier: "ImageSelect")
      self.present(imageViewController!, animated: true, completion: nil)
      }, at: 1)
  }
}


我没有在下面的程序中添加任何句子,但是出现了错误。

AppDelegate.swift

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return true
  }

  // MARK: UISceneSession Lifecycle

  func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
  }

  func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
  }


}

0 个答案:

没有答案