【发布时间】:2018-03-25 10:39:15
【问题描述】:
我的应用程序崩溃,因为它在解开值“header”时发现 nil 我尝试使用保护 let 语句,虽然它不起作用,安全解开这个值的最佳方法是什么?
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
self.headerOpen = true
if self.headerOpen == true {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerId, for: indexPath) as! HomePageHeader
header.currentUser = self.currentUser
header.usersLocation = self.usersLocation
header.delegate = self
reloadInputViews()
} else if headerOpen == false {
print("header open is false")
}
return header!
}
【问题讨论】:
标签: swift collections view