Compare commits
13 Commits
master
...
iOS6_suppo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
309329cc0c | ||
|
|
92d13ae31e | ||
|
|
351118b20e | ||
|
|
08bcc96f08 | ||
|
|
420c643f86 | ||
|
|
03ac5832c9 | ||
|
|
5d5d6a410b | ||
|
|
68ec26479f | ||
|
|
bf4a2a7525 | ||
|
|
666eace95b | ||
|
|
3a7e8b13dc | ||
|
|
eb485f2184 | ||
|
|
b81cfae779 |
@ -13,5 +13,5 @@ Pod::Spec.new do |s|
|
||||
s.frameworks = 'QuartzCore'
|
||||
s.requires_arc = true
|
||||
|
||||
s.dependency 'JSQSystemSoundPlayer'
|
||||
s.dependency 'JSQSystemSoundPlayer', '1.5.2'
|
||||
end
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
@property (assign, nonatomic) CGFloat previousTextViewContentHeight;
|
||||
@property (assign, nonatomic) BOOL isUserScrolling;
|
||||
@property (assign, nonatomic) BOOL isObserving;
|
||||
|
||||
- (void)setup;
|
||||
|
||||
@ -54,6 +55,10 @@
|
||||
((UIScrollView *)self.view).scrollEnabled = NO;
|
||||
}
|
||||
|
||||
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
|
||||
self.automaticallyAdjustsScrollViewInsets = NO;
|
||||
}
|
||||
|
||||
_isUserScrolling = NO;
|
||||
|
||||
JSMessageInputViewStyle inputViewStyle = [self.delegate inputViewStyle];
|
||||
@ -113,26 +118,31 @@
|
||||
[super viewDidLoad];
|
||||
[self setup];
|
||||
[[JSBubbleView appearance] setFont:[UIFont systemFontOfSize:16.0f]];
|
||||
self.isObserving = NO;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleWillShowKeyboardNotification:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleWillHideKeyboardNotification:)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
|
||||
[self.messageInputView.textView addObserver:self
|
||||
forKeyPath:@"contentSize"
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:nil];
|
||||
|
||||
if (!self.isObserving) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleWillShowKeyboardNotification:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleWillHideKeyboardNotification:)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
|
||||
[self.messageInputView.textView addObserver:self
|
||||
forKeyPath:@"contentSize"
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:nil];
|
||||
|
||||
self.isObserving = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
@ -141,11 +151,15 @@
|
||||
|
||||
[self.messageInputView resignFirstResponder];
|
||||
[self setEditing:NO animated:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
[self.messageInputView.textView removeObserver:self forKeyPath:@"contentSize"];
|
||||
|
||||
if (self.isObserving) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
[self.messageInputView.textView removeObserver:self forKeyPath:@"contentSize"];
|
||||
|
||||
self.isObserving = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
@ -233,7 +247,7 @@
|
||||
if ([self.delegate respondsToSelector:@selector(customCellIdentifierForRowAtIndexPath:)]) {
|
||||
CellIdentifier = [self.delegate customCellIdentifierForRowAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
|
||||
if (!CellIdentifier) {
|
||||
CellIdentifier = [NSString stringWithFormat:@"JSMessageCell_%d_%d_%d_%d", (int)type, displayTimestamp, avatar != nil, [message sender] != nil];
|
||||
}
|
||||
@ -282,6 +296,7 @@
|
||||
- (void)finishSend
|
||||
{
|
||||
[self.messageInputView.textView setText:nil];
|
||||
[self.messageInputView.textView.undoManager removeAllActions];
|
||||
[self textViewDidChange:self.messageInputView.textView];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
@ -323,7 +338,7 @@
|
||||
{
|
||||
if (self.isUserScrolling) {
|
||||
if ([self.delegate respondsToSelector:@selector(shouldPreventScrollToBottomWhileUserScrolling)]
|
||||
&& [self.delegate shouldPreventScrollToBottomWhileUserScrolling]) {
|
||||
&& [self.delegate shouldPreventScrollToBottomWhileUserScrolling]) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@ -494,9 +509,9 @@
|
||||
inputViewFrameY,
|
||||
inputViewFrame.size.width,
|
||||
inputViewFrame.size.height);
|
||||
|
||||
|
||||
[self setTableViewInsetsWithBottomValue:self.view.frame.size.height
|
||||
- self.messageInputView.frame.origin.y];
|
||||
- self.messageInputView.frame.origin.y];
|
||||
}
|
||||
completion:nil];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user