在考虑UICollectionView.
我基本上使用了以下代码: http ://www.raywenderlich.com/78551/beginning-ios-collection-views-swift-part-2
func collectionView(collectionView: UICollectionView,
viewForSupplementaryElementOfKind kind: String,
atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy' - 'HH:mm'"
//1
switch kind {
//2
case UICollectionElementKindSectionHeader:
//3
let h =
collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "eventHeaderView", forIndexPath: indexPath) as eventHeader
h.eventFirstline.text = "First Line"
h.eventSecondline.text = thisEvent.eventName
h.eventDate.text = dateFormatter.stringFromDate(thisEvent.startDate)
h.eventDescription.text = thisEvent.shortDescription
return h
default:
//4
assert(false, "Unexpected element kind")
}
}
当立即部署到模拟器或真实设备时,所有这些都可以正常工作,但奇怪的是,当我想构建一个 Ad-Hoc 包以进行测试时,它告诉我
预期返回“UICollectionReusableView”的函数中缺少返回
好的,到目前为止一切都很好,开关盒之外什么都没有,所以它什么也不会返回 - 但是为什么只有当我尝试构建一个包时它才对“热部署”发出任何警告?