我已经检查了dataSource
,如下面的屏幕截图所示。
我还实现了 override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
if kind == UICollectionElementKindSectionHeader {
var header = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "Header", forIndexPath: indexPath) as? DetailHeader
if header == nil {
header = DetailHeader()
}
return header!
} else {
println("footer")
var footer = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "Footer", forIndexPath: indexPath) as! UICollectionReusableView
return footer
}
}
方法:
println
我能够显示我的标题,但我的页脚从未显示过。 private final HibernateBundle<RestStubConfig> hibernate = new HibernateBundle<RestStubConfig>(Hotel.class) {
public DataSourceFactory getDataSourceFactory(RestStubConfig configuration) {
return configuration.getDataSourceFactory();
}
};
public static void main(String[] args) throws Exception {
new ServerStart().run(args);
}
@Override
public void run(RestStubConfig restConf, Environment env) throws Exception {
final HotelResource hotel = new HotelResource();
env.jersey().register(hotel);
}
@Override
public void initialize(Bootstrap<RestStubConfig> bootstrap) {
bootstrap.addBundle(hibernate);
}
永远不会触发。
答案 0 :(得分:4)
2.我的代码:
import UIKit
class BaseCVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cvcCell", forIndexPath: indexPath)
return cell;
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return Int(2)
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
return CGSizeMake(self.view.frame.size.width, 20)
}
override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
if kind == UICollectionElementKindSectionHeader {
let header = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "header", forIndexPath: indexPath)
return header
} else {
print("footer")
let footer = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "footer", forIndexPath: indexPath)
return footer
}
}
}
答案 1 :(得分:2)
选项1 :将footerReferenceSize
上的UICollectionViewDelegateFlowLayout
设置为大于0
选项2 :在您collectionView(_:layout:referenceSizeForFooterInSection:)
中实施UICollectionViewDelegateFlowLayout
功能。