Compare commits

...

13 Commits

Author SHA1 Message Date
Jesse Squires
309329cc0c Merge pull request #580 from uversity/iOS6_support_stable
Fixed dependency on JSQSystemSoundPlayer for iOS6_support_stable
2014-10-24 14:20:59 -07:00
Daniel Resnick
92d13ae31e Fixed dependency on systemsoundplayer 2014-10-24 11:21:10 -07:00
Jesse Squires
351118b20e Merge pull request #507 from alr/iOS6_support_stable
fix crash when user use Undo after sending text message
2014-09-25 16:26:51 -07:00
Dmitry Abolmasov
08bcc96f08 fix crash when user use Undo after sending text message 2014-09-25 22:56:02 +04:00
Jesse Squires
420c643f86 Merge pull request #350 from jcoleman/fix-kvo-issues-on-iOS6_support_stable
Fix kvo issues on iOS6_support_stable
2014-08-25 12:59:27 -07:00
James Coleman
03ac5832c9 Rename viewWillAppearHasSetupObservers to isObserving. 2014-08-25 13:51:52 -04:00
James Coleman
5d5d6a410b Use property rather than ivar for viewWillAppearHasSetupObservers. 2014-08-25 09:04:47 -04:00
James Coleman
68ec26479f Fix KVO registration/deregistration issues.
viewWillAppear and viewWillDisappear are not guaranteed to happen in any particular order; the only guarantees are that they will be called on appearance/disappearance. That is, viewWillDisappear, for example, can be called more than once. This means that for proper KVO API conformance, to register/deregister in these methods you need to keep track of whether or not you're currently observing. This fixes #180, fixes #268, fixes the issues caused by #131 and the fix in #177 that was later reverted.
2014-06-09 10:57:07 -04:00
Jesse Squires
bf4a2a7525 Merge pull request #247 from xhzengAIB/master
fix iOS7 scroll to bottom issue in v4.0
2014-04-28 08:59:15 -07:00
Jack
666eace95b Just fix the iOS7 new api. 2014-04-28 13:54:18 +08:00
Jack
3a7e8b13dc refactor method. 2014-04-28 13:01:52 +08:00
Jack
eb485f2184 fix the bug from iOS7 new api. 2014-04-28 12:55:03 +08:00
Jack
b81cfae779 fix textView the bug from iOS7. 2014-04-27 13:08:41 +08:00
2 changed files with 40 additions and 25 deletions

View File

@ -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

View File

@ -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];
}