我有两个单元格的表格视图,单元格是 UIcollectionview,每个都认为在 Xcode 中工作正常,就在我从 Diawi 应用程序获得下载链接并在那里测试它时,主页上的应用程序崩溃
(带有收集单元的表格视图)
我的主页代码是:
class HomeVC: BaseVC ,UITableViewDelegate,UITableViewDataSource,ContinueLearningDelegate,HeaderViewLearnDelegate{
@IBOutlet weak var tableView:UITableView!
@IBOutlet weak var headerView:HeaderViewLearn!
@IBOutlet weak var headerHeightConstraint:NSLayoutConstraint!
private var homeStoriesViewModel:HomeStoriesViewModel?
var shouldAnimate = true
var selectedLevel = CLoginManager.shared.user?.level
var fetchDataInViewDidAppear = false
override func viewDidLoad() {
super.viewDidLoad()
registerCells()
fetchData()
}
fileprivate func registerCells(){
tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 100, right: 0)
tableView.register(UINib(nibName: "CoursesDescTableViewCell", bundle: nil), forCellReuseIdentifier: CoursesDescTableViewCell.identifier)
tableView.register(UINib(nibName: "CoursesDataTableViewCell", bundle: nil), forCellReuseIdentifier: CoursesDataTableViewCell.identifier)
tableView.register(UINib(nibName: "ContinueLearningTableViewCell", bundle: nil), forCellReuseIdentifier: ContinueLearningTableViewCell.identifier)
tableView.dataSource = self
tableView.delegate = self
tableView.reloadData()
headerView.delegateSearchar = self
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
if let cell = tableView.dequeueReusableCell(withIdentifier: ContinueLearningTableViewCell.identifier, for: indexPath) as? ContinueLearningTableViewCell {
cell.delegate = self
cell.configure(stories:(self.homeStoriesViewModel?.getStoriesBy(indexPath.section)) ?? [])
return cell
}
}
let cell = tableView.dequeueReusableCell(withIdentifier: CoursesDescTableViewCell.identifier, for: indexPath) as! CoursesDescTableViewCell
cell.delegate = self
cell.fromHome = true
return cell
}
// TableViewCell (homePage)
class ContinueLearningTableViewCell: UITableViewCell,UICollectionViewDelegate ,UICollectionViewDataSource{
static var identifier = "ContinueLearningTableViewCellIdentifier"
@IBOutlet weak var collectionView:UICollectionView!
weak var delegate:ContinueLearningDelegate?
var stories:[Story]?
override func awakeFromNib() {
registerCells()
setupCollectionLayout()
self.selectionStyle = .none
}
private func registerCells() {
collectionView.register(UINib(nibName: "CourseProfileCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: CourseProfileCollectionViewCell.identifier)
}
private func setupCollectionLayout(){
let flowLayout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
let height = 320
flowLayout.itemSize = CGSize(width: (height), height: (height))
flowLayout.scrollDirection = .horizontal
flowLayout.minimumInteritemSpacing = 20
collectionView.collectionViewLayout = flowLayout
collectionView.delegate = self
collectionView.dataSource = self
}
func configure(stories:[Story]){
self.stories = stories
self.collectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return stories?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CourseProfileCollectionViewCell.identifier, for: indexPath) as! CourseProfileCollectionViewCell
if stories != nil {
cell.configure(story: stories![indexPath.item])
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? CourseProfileCollectionViewCell{
delegate?.onClickLessonStory(cell: cell,story:self.stories?[indexPath.item])
}
}
override func prepareForReuse() {
super.prepareForReuse()
}
}
the Log print :-
Last Exception Backtrace:
0 CoreFoundation 0x1b61a896c __exceptionPreprocess + 224
1 libobjc.A.dylib 0x1b5ec1028 objc_exception_throw + 59
2 CoreFoundation 0x1b60a6dcc -[NSObject+ 200140 (NSObject) doesNotRecognizeSelector:] + 143
3 UIKitCore 0x1ba2d8884 -[UIResponder doesNotRecognizeSelector:] + 303
4 CoreFoundation 0x1b61ad048 ___forwarding___ + 1327
5 CoreFoundation 0x1b61af3a0 _CF_forwarding_prep_0 + 95
6 ChaLearn 0x10494cb20 _hidden#1889_ + 527136 (__hidden#9146_:74)
7 ChaLearn 0x10494aec4 _hidden#8966_ + 519876 (__hidden#9004_:60)
8 ChaLearn 0x10494af9c _hidden#8967_ + 520092 (__hidden#419_:0)
9 UIKitCore 0x1b9adad00 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 443
10 UIKitCore 0x1b9adf6e8 -[UICollectionView _updateVisibleCellsNow:] + 4475
11 UIKitCore 0x1b9ae4244 -[UICollectionView layoutSubviews] + 323
12 UIKitCore 0x1ba75c8b0 -[UIView+ 15689904 (CALayerDelegate) layoutSublayersOfLayer:] + 2155
13 libobjc.A.dylib 0x1b5ebca4c -[NSObject performSelector:withObject:] + 67
14 QuartzCore 0x1bcd7255c -[CALayer layoutSublayers] + 291
15 QuartzCore 0x1bcd729ac CA::Layer::layout_if_needed+ 1403308 (CA::Transaction*) + 483
16 UIKitCore 0x1ba748210 -[UIView+ 15606288 (Hierarchy) layoutBelowIfNeeded] + 551
17 UIKitCore 0x1ba74ed54 +[UIView+ 15633748 (Animation) performWithoutAnimation:] + 103
18 UIKitCore 0x1ba4997b0 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1123
19 UIKitCore 0x1ba466088 -[UITableView _updateVisibleCellsNow:] + 2591
20 UIKitCore 0x1ba483838 -[UITableView layoutSubviews] + 163
21 UIKitCore 0x1ba75c8b0 -[UIView+ 15689904 (CALayerDelegate) layoutSublayersOfLayer:] + 2155
22 libobjc.A.dylib 0x1b5ebca4c -[NSObject performSelector:withObject:] + 67
23 QuartzCore 0x1bcd7255c -[CALayer layoutSublayers] + 291
24 QuartzCore 0x1bcd729ac CA::Layer::layout_if_needed+ 1403308 (CA::Transaction*) + 483
25 QuartzCore 0x1bcd851bc CA::Layer::layout_and_display_if_needed+ 1479100 (CA::Transaction*) + 139
26 QuartzCore 0x1bccc9b00 CA::Context::commit_transaction+ 711424 (CA::Transaction*, double) + 307
27 QuartzCore 0x1bccf4910 CA::Transaction::commit+ 887056 () + 683
28 QuartzCore 0x1bccf54e4 CA::Transaction::observer_callback+ 890084 (__CFRunLoopObserver*, unsigned long, void*) + 95
29 CoreFoundation 0x1b6123524 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 35
30 CoreFoundation 0x1b611e1c4 __CFRunLoopDoObservers + 419
31 CoreFoundation 0x1b611e774 __CFRunLoopRun + 1291
32 CoreFoundation 0x1b611df40 CFRunLoopRunSpecific + 479
33 GraphicsServices 0x1c03ae534 GSEventRunModal + 107
34 UIKitCore 0x1ba2a9580 UIApplicationMain + 1939
35 ChaLearn 0x1048d23d0 main + 25552 (__hidden#417_:24)
36 libdyld.dylib 0x1b5f9ce18 start + 3
我有两个单元格的表格视图,单元格是 UIcollectionview,每个都认为在 Xcode 中工作正常,就在我从 Diawi 应用程序获得下载链接并在那里测试它时,主页上的应用程序崩溃
(带有收集单元的表格视图)
我的主页代码是:
这是我的代码和日志错误,有什么帮助吗?