我发生了崩溃,但只是第一次安装并运行应用程序。崩溃的原因如下:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OnBoardViewController info:]: unrecognized selector sent to instance 0x7f86f4c1f090'
正如您所看到的,选择器info
不在班级中。这是OnBoardViewController
类
import Foundation
import UIKit
class OnboardViewController : UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet var onBoardView : UICollectionView!
@IBOutlet var onBoardViewLayout: UICollectionViewFlowLayout!
@IBOutlet var pageIndicator: UIPageControl!
// MARK: VC lifecycle
override func viewDidLoad() {
onBoardView.delegate = self
onBoardView.dataSource = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: false)
}
override func viewDidLayoutSubviews() {
configureCollectionView()
}
// MARK: UI
func configureCollectionView () {
onBoardView.isPagingEnabled = true
onBoardView.bounces = false
onBoardView.showsHorizontalScrollIndicator = false
onBoardViewLayout.itemSize = onBoardView.bounds.size
onBoardViewLayout.minimumInteritemSpacing = 0.0
onBoardViewLayout.minimumLineSpacing = 0.0
onBoardViewLayout.sectionInset = UIEdgeInsets.zero
}
// MARK: Scroll delegates
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentPage = ceil(scrollView.contentOffset.x / scrollView.bounds.size.width)
pageIndicator.currentPage = Int(currentPage)
}
// MARK: UICollectionView delegates
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "onboardCellID", for: indexPath) as! OnboardCell
cell.screen = indexPath.item
return cell
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
}
在此次崩溃后,我重新启动了应用程序,它不再崩溃。如果我删除该应用程序,再次安装并启动它,则会重复相同的崩溃。