|
@@ -12,6 +12,9 @@
|
|
|
|
|
|
@interface YMIMMessageCollectionView()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate>
|
|
|
|
|
|
+@property (nonatomic, assign) BOOL scrollViewDidEnd;
|
|
|
+
|
|
|
+@property (nonatomic, assign) CGFloat scrollViewOfsetY;
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -69,6 +72,11 @@
|
|
|
{
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
if (self.chatDataManager.count > 0) {
|
|
|
+// UIScrollView * scrollView= self.messageCollectionView;
|
|
|
+// CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
|
|
|
+// self.scrollViewDidEnd = NO;
|
|
|
+// [scrollView setContentOffset:bottomOffset animated:YES];
|
|
|
+
|
|
|
NSIndexPath *endIndex = [NSIndexPath indexPathForItem:self.chatDataManager.count - 1 inSection:0];
|
|
|
[self.messageCollectionView scrollToItemAtIndexPath:endIndex atScrollPosition:UICollectionViewScrollPositionBottom animated:animated];
|
|
|
}
|
|
@@ -348,9 +356,34 @@
|
|
|
}
|
|
|
return CGSizeMake(kSCREEN_WIDTH, height);
|
|
|
}
|
|
|
+//
|
|
|
+//- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
|
|
+//{
|
|
|
+// return [[UICollectionReusableView alloc] initWithFrame:CGRectZero];
|
|
|
+//}
|
|
|
+//
|
|
|
+//
|
|
|
+//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
|
|
|
+// return CGSizeZero;
|
|
|
+//}
|
|
|
+
|
|
|
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
|
+ if (self.scrollViewDidEnd && self.scrollViewOfsetY - scrollView.contentOffset.y > 15) {
|
|
|
+ self.scrollViewDidEnd = NO;
|
|
|
+ self.scrollViewOfsetY = 0.0f;
|
|
|
+ [self.viewController.view endEditing:YES];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
|
|
-{
|
|
|
+- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
|
|
|
+ CGFloat ty = self.superview.transform.ty;
|
|
|
+ if (ty < 0) {
|
|
|
+ self.scrollViewDidEnd = YES;
|
|
|
+ self.scrollViewOfsetY = scrollView.contentOffset.y;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
|
|
|
|
|
|
}
|
|
|
|