5

I have a custom view that I am using as inputAccessoryView for my tableViewController.

the tableViewControlleris inside a tabBarViewController which is inside a navigation controller.

I managed to make the custom view appear correctly as the inputAccessoryView, appearing at the bottom, and when focused it goes up with the keyboard.

My problem is that it's hiding my tabBar, I searched but couldn't find anything except for a 2years old unanswered question. I want my view to appear above the tabBar, similar to the music app when having a song playing, the song and the play button and the next button appear above the tabBar not hiding it.

using swift 4.2, Xcode 10.1, iOS 11 target, testing on iOS 12.1 and 12.1.1

user773277
  • 108
  • 9
  • 1
    Technically, the inputAccessoryView is "part" of the keyboard, so the tab bar shouldn't split it into. A more "compliant" solution is to move the tab bar above the keyboard: https://stackoverflow.com/questions/5272267/keyboard-hides-tabbar/14782487#14782487 – Renaud Dec 15 '18 at 12:14
  • 2
    the inputAccessoryView does move with the keyboard, but that's not my problem, the problem is when there is no keyboard it's hiding the tabBar. i want my view to be above the tabBar, similar to musics app when you have a song player the song and play and forward buttons appear above the tabBar – user773277 Dec 15 '18 at 12:16
  • 1
    OK, I misunderstood your question. What I would do then is to use a subclass of `UIViewController` instead of the `UITableViewController`, with two subviews: the `UITableView` and your custom view (you can't really add a subview to a `UITableView` and `UITableViewController` requires its view to be a `UITableView`). Then you can anchor the custom view to the safe area and it should remain on top of the tab bar, and add some content inset to your table view so that it scrolls properly. – Renaud Dec 15 '18 at 12:32
  • I guess I will have to do that and handle keyboard movement. Thanks :) – user773277 Dec 16 '18 at 09:54

1 Answers1

3

I have been able to achieve this effect and made a framework called AMKeyboardFrameTracker to do just that

AMKeyboardFrameTracker.gif

but first you need to understand how the inputAccessoryView work

inputAccessoryView is attached to another window called UITextEffectsWindow this window shows on top of your main app window

The main feature of using inputAccessoryView is the interactive keyboard dismissal effect with any UIScrollView because normally you can't get the keyboard frame from the native keyboard notifications callbacks

But with AMKeyboardFrameTracker I've been able to get the keyboard frame from the inputAccessoryView's superview by observing it's frame changes, so it's still using inputAccessoryView but with an empty view that has no user interaction

There is an Example in the Github repo you can download it and try it out

Note in the example app I am using a normal ViewController instead of a TableViewController if you'd like to use a TableViewController you can still achieve this by adding your CustomView to the navigationController's view

Amr Mohamed
  • 2,290
  • 4
  • 20
  • 39
  • your suggested lib. working on without tabbar viewcontroller ? I have face issue of - https://github.com/iAmrMohamed/AMKeyboardFrameTracker/issues/4 – PT Vyas Sep 01 '20 at 05:52