0

I was wondering if anyone has seen a similar problem to this where you have a random blank space between the keyboard and a UITextField? For some reason I can't find anything about this and the end of the screen is the bottom of the UITextField. Any help would be greatly appreciated.

Example Screenshot showing space between keyboard and UITextField

modusCell
  • 13,151
  • 9
  • 53
  • 80
NuttGuy
  • 87
  • 1
  • 6
  • So you want the bottom of the text field to be just above the keyboard? – AdamPro13 Aug 10 '14 at 20:24
  • @AdamPro13 Yes that would be the preferred behavior – NuttGuy Aug 10 '14 at 20:42
  • Is your `UITextField` in a `UIScrollView`? – AdamPro13 Aug 10 '14 at 21:22
  • @AdamPro13 I don't think so? (Note I'm a little bit new to this) this is what the header looks like: `@interface UserTableViewController : UITableViewController @property (nonatomic, strong) NSString *friendUser; @property (weak, nonatomic) IBOutlet UITextField *MessageText;` So basically it's just a page that shows a table of information and then a UITextField to take input from the user. – NuttGuy Aug 10 '14 at 21:29

1 Answers1

0
  1. Start by putting the text field in a UIScrollView.
  2. Register your view controller to respond to the notification UIKeyboardDidShowNotification. This notification will give you a dictionary that has the size of the keyboard.
  3. Once you have the size value, you will have to do some math to figure out what you want the scroll view's contentInset to be such that the text field is just above it.

Here's an example for getting the size of the keyboard: How to get UIKeyboard size with Apple iPhone SDK

Community
  • 1
  • 1
AdamPro13
  • 7,232
  • 2
  • 30
  • 28