1

Hi there I have a UIView with a bunch of UITextfields. My problem is that my UITextfields are present from the top to the bottom of my screen. So when the keyboard pops up, it covers half the screen and consequently the UITextfields below...What can I do so that all the fields can be edited by simmply scrolling when the keyboard is visible? enter image description here

enter image description here

banditKing
  • 8,915
  • 26
  • 89
  • 151

3 Answers3

1

You need to embed your UIView into a UIScrollView and then change the size of the UIScrollView when the keyboard pops up.

David
  • 13,850
  • 20
  • 90
  • 143
1

Just give the view a new transform that moves it up. Eg.

[myView setTransform:CGAffineTransformMakeTranslation(0, -keyboardSize.height)];

Thats also animatable, just give it the same animation values as the keyboards and it will look perfect.

JustSid
  • 24,711
  • 7
  • 72
  • 97
  • Im new to iPhone dev, so Im not sure exactly how the above mentioned method will work. Where should I put it. I tried putting it in the viewDidLoad method but then I get and error XCode doesn't recognize "keyboardsize" – banditKing Apr 10 '11 at 00:28
  • No offense, but maybe you should read the documentation about UIViews, UIViewControllers and Objective-C first? Its btw called "Xcode" not "XCode" or "xCode" – JustSid Apr 10 '11 at 00:30
0

This solution is from XCode 5, iOS 7.0 and Storyboards. It worked for me quite well.

http://www.youtube.com/watch?v=4oCWxHLBQ-A

Nick N
  • 844
  • 8
  • 19