12

I'm trying to figure out the best way to have a custom inputAccessoryView rest on top of a tab bar. Currently, I have an inputAccessoryView that rests at the very bottom of the screen, but it covers the tab bar. Any one know the best practice for shifting that inputAccessoryView up?

Currently I have a view defined in a storyboard with a tab bar. Its corresponding view controller takes the view and calls becomeFirstResponder. I've overwritten both: - (UIView *)inputAccessoryView and -(BOOL)canBecomeFirstResponder within the view's .m

CatLord
  • 361
  • 1
  • 4
  • 14
  • Hi, did you manage to fix this? – Josh Apr 27 '17 at 10:59
  • From what I found @Josh , Apple seems to discourage this approach. I ended up removing the tab bar by pushing the view over the tab bar controller which allowed me to avoid having to do what I described above. The only solution I could find here that seemed to work was using a UIToolbar instead, placing that above the tab bar, and using that as the input view. Sorry I can't be of more help! – CatLord Apr 28 '17 at 13:31

1 Answers1

0

Found a workaround by shifting toolbar frame by bottomSpacing = tabbar height:

- (void) layoutSubviews {
    [super layoutSubviews];
    CGRect origFrame = self.frame;
    origFrame.origin.y = _keyboardIsVisible ? 0 : -self.bottomSpacing;
    self.frame = origFrame;
}

Strangely it works well in JSQMessagesInputToolbar, but it's lost after animations if I do this in UIView that wraps toolbar, or maybe I'm missing something..

Luten
  • 5,420
  • 4
  • 26
  • 24