I am using JSQMessagesViewController for my chat application. When there is no internet activity I would like to hide the inputToolbar
I tried this, but that does not work:
self.inputToolbar.frame.size = CGSize(width: 0,height: 0)
When I set this, then for less than a second it's gone:
self.inputToolbar.preferredDefaultHeight = 0
Any idea how to do this? Maybe disabling the inputToolbar could also be good enough.
I found a better solution which doesn't have any side effects.
You can make the actions in a descendant class of JSQMessagesViewController.
1. Make this method of base class available for you:
@interface JSQMessagesViewController ()
- (void)jsq_setCollectionViewInsetsTopValue:(CGFloat)top
bottomValue:(CGFloat)bottom;
@end
2. Override parent realization of method (called when size changed):
- (void)jsq_updateCollectionViewInsets {
CGFloat topInset = self.topLayoutGuide.length + self.topContentAdditionalInset;
CGFloat bottomInset = 0.0;
[self jsq_setCollectionViewInsetsTopValue:topInset bottomValue:bottomInset];
}
3. Write the method to hide input toolbar forever:
- (void)hideInputToolbar {
self.inputToolbar.hidden = YES;
[self jsq_updateCollectionViewInsets];
}
4. Enjoy!
Instead of removing from superview and having to add back as a subview, why not just use:
[self.inputToolbar setHidden:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With