So I have a UITableView where one of its rows is a UITextView.
When the user is writing something to UITextView (using the keyboard) the user can scroll the tableview and select another cell. Everything works.
When the user selects another cell, a datePicker appears, and the user can select a given date. I want the user to be able to scroll the tableView the same way like when the keyboard is on the screen.
The problem here is that when I scroll with the picker, the table bounces back to the previous position (with some cells hidden by the picker).
I assume that this happens because I add the picker to the main window, as a subview… but I’m honestly not sure…
Where (and how) should I add my picker so that it “appears” where the keyboard appears?
Not sure I was clear…
Thanks a lot.
I actually did this with the UIDatePicker, created my own SlideUpDatePicker that animated up from the bottom just like the keyboard. It took me a week or two to get it all working perfectly, it was definitely not easy to get it to work in portrait and landscape and with a nav controller and its animations.
The keyboard creates a new top level window to hold its view and it posts notifications to the notification center before and after it appears and disappears so that the view controller can adjust the size of it’s view to account for the keyboard. The view controller needs to handle those notifications and resize the tableview by the size of the keyboard.
My SlideUpDatePicker posted the same notifications as the keyboard so the view controller wouldn’t have to be modified and could respond the same for both the keyboard and the slide up date picker.
If you use the dumpWindows() function you can see the UIWindow and UIView hierarchy with the keyboard and a table view in a navigation based app: