ios - 奇怪的错误,当尝试滚动到底部时,collectionView View 滚动到倒数第二条消息

标签 ios swift uiscrollview uicollectionview

使用此代码滚动到 Collection View 的底部。但是它只会滚动到倒数第二个。

private func scrollToBottom() {
    let lastSectionIndex = (ChatCollectionView?.numberOfSections())! - 1
    let lastItemIndex = (ChatCollectionView?.numberOfItemsInSection(lastSectionIndex))!-1
    let indexPath = NSIndexPath(forItem: lastItemIndex, inSection: lastSectionIndex)

    ChatCollectionView!.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.Bottom, animated: false)
}

有人熟悉这样的错误吗

最佳答案

您的 Collection View 的框架位于可见区域下方。您应该将其底部设置在可见区域内。

关于ios - 奇怪的错误,当尝试滚动到底部时,collectionView View 滚动到倒数第二条消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38799838/

相关文章:

ios - 在CollectionView中设置backgroundView后,刷新 Controller 不会出现

ios - ScrollView contentSize 大于边界,但没有滚动

swift - 在 ScrollView 中拖动 uiview

ios - 如何在 iOS 中检测连续两次点击

objective-c - Apple 的 Reachability 文件中的奇怪错误

ios - 无法使用 cloudkit 从公共(public)数据库中获取记录

java - 从 Cloud Firestore 获取 map 数据

arrays - Swift 2 NSUserDefaults 读取数组

ios - 设备旋转后的 UICollectionView contentOffset

ios - iOS UITableView如何在NavigationBar下使用?