首页 > 解决方案 > Swift 线程 1:EXC_BAD_ACCESS(代码=2,地址=0x7ffeedbbaff8)

问题描述

我正在尝试让 pod 工作。它来自这里:

https://github.com/Ahmadalsofi/SOTabBar

直到运行时我才收到错误,在那里我得到了一长串看起来像是线程循环的东西。

图片:

1.踏栈

2.发生错误的行

3.错误信息

  1. 我可以将错误追踪到:

我的场景委托进入应用程序:(我没有使用故事板)

    class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?


    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        window?.rootViewController = MainTabBarVC()
        window?.makeKeyAndVisible()
    }
}

我的 MainTabBarVC:

import UIKit
import SOTabBar
class MainTabBarVC: SOTabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let firstVC = SearchVC(nibName: "Main", bundle: nil)
        let secondVC = TestVC(nibName: "Main", bundle: nil)



        firstVC.tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "mappin.and.ellipse"), selectedImage: UIImage(systemName: "star"))
        secondVC.tabBarItem = UITabBarItem(title: "Chat", image: UIImage(named: "secondImage"), selectedImage: UIImage(systemName: "mappin.and.ellipse"))
        viewControllers = [firstVC, secondVC]

    }


    override func loadView() {
         super.loadView()
         SOTabBarSetting.tabBarHeight = 60.0
         SOTabBarSetting.tabBarTintColor = UIColor.red
        SOTabBarSetting.tabBarBackground = UIColor.purple
        SOTabBarSetting.tabBarCircleSize = CGSize(width: 50.0, height: 50.0)
        SOTabBarSetting.tabBarSizeImage = CGFloat(20)

        SOTabBarSetting.tabBarSizeSelectedImage = CGFloat(40)
        SOTabBarSetting.tabBarAnimationDurationTime = 2
    }
}

extension MainTabBarVC: SOTabBarControllerDelegate {

    func tabBarController(_ tabBarController: SOTabBarController, didSelect viewController: UIViewController) {
        print("Hello")
    }


}

我的 SearchVC 和 TestVC 只是具有不同背景颜色的简单 VC,例如:

import UIKit

class SearchVC: UIViewController {


    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .systemRed

    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }


}

视图控制器本身很好,问题似乎是 pod。我尝试查看他们的 github 源代码,但我不知道是什么原因造成的。所以问题要么是 pod,要么是我的实现。

标签: swift

解决方案


推荐阅读