3

I have a tab bar controller-based application and I am using IQKeyboardManager to handle form-like stuff.

screenshot of blank space in IQKeyboardManager

Step 1: Tab bar controller with bottom a UITextView inside a UIView. Check Image 1.

Step2: When I click on UITextView, the keyboard appears but a blank space is appearing due to the tab bar. I have tried to remove IQKeyboardManager but it still occurs, so it is confirmed that it is not the issue of IQKeyboardManager. It is an issue due to the tab bar controller.

How to remove that spacing?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Hardik Shah
  • 1,683
  • 1
  • 11
  • 20

1 Answers1

4

You are correct. The blank space is caused by the tab bar. Override the y position in the view by adding the additional space when you receive keyboard should appear and not in your viewDidLoad or any place else because it will then be hidden behind the tab bar. Then you need to set it back to normal by removing that added value when the user is finished using the keyboard. eg.

// Declaration
var tabBarHeight : CGFloat = 0.0
// viewDidLoad
tabBarHeight = tabBarController?.tabBar.frame.size.height
// When the user begins using the keyboard move the view containing the textfield
yourView.frame.origin.y = (tabBarController?.tabBar.frame.origin.y + tabBarHeight )
// When the user finishes using the keyboard
yourView.frame.origin.y = (tabBarController?.tabBar.frame.origin.y - tabBarHeight )

If you have constraints, you will need to adjust them. Good answer here:

https://stackoverflow.com/a/27870216/4008175

This answer will assist you in listening to when the keyboard has been activated and deactivated:

https://stackoverflow.com/a/27087733/4008175

Good luck!

App Dev Guy
  • 5,396
  • 4
  • 31
  • 54
  • @HardikShah I adjusted my answers. You need to update the frame position of your textview's parent view. See the updated answer. – App Dev Guy May 25 '17 at 07:28