1

According to the answer at UITableView, make footer stay at bottom of screen?, which I verify:

In order to have a footer that stays put at the bottom of the screen, and doesn't scroll with the table, then you can't use a table view footer. You can't even use a UITableViewController, you'll need to implement your view controller as a UIViewController. Then you add your own table view as a subview. You'll also need to add your footer as a subview of the view controller's view, not the table view. Make sure you size the table view so its bottom is at the top of the footer view.

but the problem is that my UITextField, inside my footer, is being hidden by the keyboard when user tries to type. So how do I keep the keyboard from hiding the UITextField? Throughout the app, I have been using TPKeyboardAvoiding. But in this case, where a UIScrollView/TPKeyboardAvoidingScrollView contains a UITableView and a UIView in vertical order, it does not work. I generally like TPKeyboardAvoiding because it’s so quick and easy. Any ideas how I might fix this issue?

Community
  • 1
  • 1
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • Can't you do it the old-fashioned way but sliding up self.view of the UIViewController and then sliding it down again? – Darren Sep 25 '14 at 03:56
  • @Darren, I am looking at that. But the best code I find so far has the keyboard data hard-coded as magic numbers. So I am looking for ways to combine that code with keyboard notification somehow. The code is http://stackoverflow.com/questions/1247113/iphone-keyboard-covers-uitextfield?rq=1 – Katedral Pillon Sep 25 '14 at 04:15
  • Don't add the UITextField into your UITableView's footer. Add it as a subview of the UIViewController as stated in the quoted text. – Zhang Sep 25 '14 at 04:57
  • Thanks for all the replies. But unfortunately, not one of them is of much help :) You guys are just repeating exactly what I said I already did. I **am** using a UIViewController and a UITableView and a UIView below the UITableView. The UIView that I am using as "footer" contains a UITextField and a Button. I am the one who provided the quote. So No. I am not using a UITableView footer. Anyway. I new code I find has some issues in that it shows a black screen for a moment after the keyboard is gone. Plus the numbers are hardcoded magic numbers. Any ideas how to fix those issues? – Katedral Pillon Sep 25 '14 at 05:19

2 Answers2

1

The instruction that you quote is telling you to use a UIViewController, add a UITableView as a subview, then add a UITextField as a subview of the UIViewController NOT as a subview of the UITableView.

Let me draw it out for you:

Step 1:

Add a UITableView to your view controller

enter image description here

Step 2:

Add your UITextField subview (you can embed the UITextField in a UIView container if you like) as a subview of your UIViewController's view NOT your UITableView footer.

enter image description here

Step 3:

If depending on if your using frames or autolayout, you adjust the frame or autolayout constraint constant values for your UITextField subview when user tap on the text field.

enter image description here

Step 4:

Finally, the keyboard appears and the UITextField doesn't get obscured by the keyboard.

enter image description here

Zhang
  • 11,549
  • 7
  • 57
  • 87
0

Just make sure your UITableView doesn't initialize it's own automatic scrolling for keyboard appearing. If you use UITableViewController then just subclass it and make sure you don't call it's viewWillAppear:. I didn't investigate which exactly method you should block without using UITableViewController, so, you should find out this yourself or somebody else would help.

I did similar in my own project where I wanted to have own scrolling of table view for keyboard appearing.

Vitaly
  • 515
  • 3
  • 9