代码之家  ›  专栏  ›  技术社区  ›  Claire Cho

线程1:信号SIGABRT,黑屏,“无法加载捆绑包中的NIB”[重复]

  •  0
  • Claire Cho  · 技术社区  · 8 年前

    当我启动模拟器时,一个黑屏出现了!与AppDelegate中的错误“线程1:信号SIGABRT”相同。最后,右角的一个错误告诉我,他们无法在捆绑包中加载NIB。我对编码也很陌生,所以我还有很多东西要学。如果你喜欢,你可以给我一些提示。如果您需要查看,以下是我的代码:

    import UIKit
    
    class ViewController: UIViewController {
        public var screenWidth: CGFloat {
            return UIScreen.main.bounds.width/100
        }
        var thereIsInternet:Bool?
        var reachability:Reachability?
        var numberTowardCompletion = 0
        override func viewDidLoad() {
            super.viewDidLoad()
            barProgress.frame.size.width = 0
            // Do any additional setup after loading the view, typically from a nib.
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
            barProgress.frame.size.width = 0
            self.reachability = Reachability.init()
            if ((self.reachability!.connection) != .none) {
                thereIsInternet = true
            } else {
                thereIsInternet = false
            }
            let when = DispatchTime.now() + 5
            DispatchQueue.main.asyncAfter(deadline: when) {
    
            }
        }
    
    
        @IBOutlet weak var barProgress: UIView!
        @IBOutlet var percent: UILabel!
        @IBOutlet var loading: UILabel!
    
        func checkingInternet() {
            if thereIsInternet == true {
                loading.text = "Internet is present"
                barProgress.frame.size.width = screenWidth * CGFloat(15)
            } else {
                loading.text = "ERROR"
                let alert = UIAlertController(title: "Connection Problem", message: "Make sure you're connected to the internet", preferredStyle: .alert)
                let restartAction = UIAlertAction(title: "Restart", style: .default, handler: { (UIAlertAction) in
                    self.startOver()
                })
                alert.addAction(restartAction)
                present(alert, animated: true, completion: nil)
            }
        }
        func startOver() {
            barProgress.frame.size.width = 0
            self.reachability = Reachability.init()
            if ((self.reachability!.connection) != .none) {
                thereIsInternet = true
            } else {
                thereIsInternet = false
            }
            let when = DispatchTime.now() + 5 // change 2 to desired number of seconds
            DispatchQueue.main.asyncAfter(deadline: when) {
    
            }
            checkingInternet()
        }
    }
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Shehata Gamal    8 年前

    在Appdelegate中尝试此操作,其中ViewControllerHere是viewcontroller xib文件的名称

    self.window.rootViewController = ViewController(nibName: "ViewControllerHere", bundle: nil)
    

    enter image description here