Fix scroll to bottom bug

This commit is contained in:
kevinzhow
2015-04-21 19:48:35 +08:00
parent e6ec44b478
commit 57894e8d54
@@ -18,7 +18,7 @@ class ConversationViewController: UIViewController {
return messagesInConversation(self.conversation)
}()
let messagesBunchCount = 12 // TODO:
let messagesBunchCount = 50 // TODO:
var displayedMessagesRange = NSRange()
@@ -401,11 +401,11 @@ class ConversationViewController: UIViewController {
//
if !conversationCollectionViewHasBeenMovedToBottomOnce {
conversationCollectionViewHasBeenMovedToBottomOnce = true
// contentInset
setConversaitonCollectionViewOriginalContentInset()
if displayedMessagesRange.length > 0 {
conversationCollectionView.scrollToItemAtIndexPath(NSIndexPath(forItem: displayedMessagesRange.length - 1, inSection: 0), atScrollPosition: UICollectionViewScrollPosition.Bottom, animated: false)
}
@@ -969,11 +969,17 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
conversationCollectionViewHasBeenMovedToBottomOnce = true
}
// MARK: UIScrollViewDelegate
func scrollViewDidScroll(scrollView: UIScrollView) {
pullToRefreshView.scrollViewDidScroll(scrollView)
println("Scrolled\(scrollView.contentOffset.y)")
}
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {