按下按钮时增加 collectionview 单元格的高度并滚动到底部
Increase the height of collectionview cell on button press and scroll to bottom
我有一个使用以下方法实现的集合视图控制器
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: 661)
}
我硬编码了一个高度值,但是当我按下一个按钮时,我希望单元格的高度为 800 并滚动到单元格底部。(我只有一个单元格)。请帮忙
var dynamicHeight = 661
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: dynamicHeight )
}
@IBAction func yourButton(_ sender: Any?)
{
self.dynamicHeight = 800
self.collectionView.reloadData()
}
我有一个使用以下方法实现的集合视图控制器
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: 661)
}
我硬编码了一个高度值,但是当我按下一个按钮时,我希望单元格的高度为 800 并滚动到单元格底部。(我只有一个单元格)。请帮忙
var dynamicHeight = 661
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: dynamicHeight )
}
@IBAction func yourButton(_ sender: Any?)
{
self.dynamicHeight = 800
self.collectionView.reloadData()
}