如何修复“由于未捕获的异常而正在终止应用程序...”

时间:2019-06-19 15:19:07

标签: ios swift xcode uicollectionview

我正在构建一个使用uiCollectionView的应用程序,但是每次运行该应用程序时,都会收到错误消息:“线程1:信号SIGABRT”,我之前曾遇到过此类错误,但是这次我无法弄清楚我做错了。

  

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法在捆绑包中加载NIB:'NSBundle   这是我的代码:

import Foundation
import UIKit
class HomeViewController: UIViewController{

    override func viewDidLoad(){
        super.viewDidLoad()

    }

var eventTitle = ""
var dueDate = ""
var datePosted = ""
var eventDescription = ""

@IBOutlet weak var viewAllThingsToDo: UIButton!

@IBOutlet weak var viewAllGetItDone: UIButton!

@IBAction func viewAllThingsToDoAction(_ sender: Any) {

    func TtdButtonPressed (dueDate: Date, title: String,     datePosted: Date, Description: String?) {


    }

}
@IBOutlet weak var GIDCollectionView: ThingsToDoCollectionView!

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "homeToDetailedEvents" {
        let destVc = segue.destination as! DetailedEventsViewController
        destVc.eventTitle = eventTitle
        destVc.dueDate = dueDate
        destVc.datePosted = datePosted
        destVc.eventDescription = eventDescription
    }
}
@IBAction func viewAllGetItDoneAction(_ sender: Any) {

}







}


extension HomeViewController: UICollectionViewDataSource {


func collectionView(_ collectionView: UICollectionView,     numberOfItemsInSection section: Int) -> Int {
    return 1
}

func collectionView(_ collectionView: UICollectionView,     cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

let nib = UINib(nibName: "ThingsToDoCollectionViewCell", bundle: nil)
    collectionView.register(nib, forCellWithReuseIdentifier: "ThingsToDoCollectionViewCell")


    let cell =    collectionView.dequeueReusableCell(withReuseIdentifier: "ThingsToDoCollectionViewCell", for: indexPath)

    if let myCVC = cell as? ThingsToDoCollectionViewCell {
        myCVC.GIDTitle.text = "Title"
        myCVC.GIDDueDate.text = "June 17"
        myCVC.GIDThumbnail.image = UIImage(named: "IMG_7070")
    }
    return cell
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
    return 1
}

}

extension HomeViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView,  didSelectItemAt indexPath: IndexPath) {
    print(indexPath)
}
}

0 个答案:

没有答案