线程 1:SIGABRT 信号、黑屏和 'Could not load NIB in bundle'
Thread 1: signal SIGABRT, black screen, and 'Could not load NIB in bundle'
当我启动模拟器时,出现黑屏!与 AppDelegate 中的 "Thread 1: signal 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()
}
}
在 Appdelegate 中尝试此操作,其中 ViewControllerHere 是 viewcontroller xib 文件的名称
self.window.rootViewController = ViewController(nibName: "ViewControllerHere", bundle: nil)
当我启动模拟器时,出现黑屏!与 AppDelegate 中的 "Thread 1: signal 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()
}
}
在 Appdelegate 中尝试此操作,其中 ViewControllerHere 是 viewcontroller xib 文件的名称
self.window.rootViewController = ViewController(nibName: "ViewControllerHere", bundle: nil)