MessagesVC: Scrolls to bottom and fixes jumpiness

This commit is contained in:
dtsbourg 2014-12-29 21:23:20 +01:00 committed by Frederic Jacobs
parent a93b111458
commit 5961c635e0
3 changed files with 16 additions and 12 deletions

View File

@ -81,7 +81,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
JSQMessagesViewController:
:commit: 6a30411791a52d1a605fa03733eab8ce47655b7f
:commit: 84d1b659f350ac3e10464d44b87243fa4622acf4
:git: https://github.com/dtsbourg/JSQMessagesViewController
SocketRocket:
:commit: d0585af165

View File

@ -45,5 +45,12 @@
{
return [UIColor colorWithRed:195.f/255.f green:0 blue:22.f/255.f alpha:1.f];
}
+ (UIColor *) ows_lightBackgroundColor
{
return [UIColor colorWithRed:242.f/255.f green:242.f/255.f blue:242.f/255.f alpha:1.f];
}
@end

View File

@ -141,6 +141,7 @@ typedef enum : NSUInteger {
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.automaticallyScrollsToMostRecentMessage = YES;
[self scrollToBottomAnimated:NO];
}
@ -155,6 +156,7 @@ typedef enum : NSUInteger {
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self startReadTimer];
[self scrollToBottomAnimated:YES];
}
- (void)viewWillDisappear:(BOOL)animated{
@ -216,7 +218,7 @@ typedef enum : NSUInteger {
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.automaticallyScrollsToMostRecentMessage = YES;
self.automaticallyScrollsToMostRecentMessage = NO;
self.collectionView.collectionViewLayout.incomingAvatarViewSize = CGSizeZero;
self.collectionView.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero;
@ -260,14 +262,6 @@ typedef enum : NSUInteger {
}
}
#pragma mark - JSQMessage custom methods
-(void)updateMessageStatus:(JSQMessage*)message {
if ([message.senderId isEqualToString:self.senderId]){
message.status = kMessageReceived;
}
}
#pragma mark - JSQMessagesViewController method overrides
- (void)didPressSendButton:(UIButton *)button
@ -502,7 +496,7 @@ typedef enum : NSUInteger {
return 16.0f;
}
}
else if (msg.messageType == TSOutgoingMessageAdapter) {
else if ([self shouldShowMessageStatusAtIndexPath:indexPath]) {
return 16.0f;
}
@ -822,7 +816,9 @@ typedef enum : NSUInteger {
return;
}
[self.collectionView performBatchUpdates:^{
for (YapDatabaseViewRowChange *rowChange in messageRowChanges)
{
switch (rowChange.type)
@ -855,8 +851,9 @@ typedef enum : NSUInteger {
}
}
}
} completion:^(BOOL finished) {
[self finishReceivingMessage];
[self scrollToBottomAnimated:YES];
}];
}