1

I have a login screen controller with few form objects. When the user click any form objects, iOS keyboard is appearing on my Login Button

enter image description here

enter image description here

And have to click any other area to close keyboard then click login button for login. How to slide up these form objects when the keyboard appear?

Mehmet
  • 3,083
  • 8
  • 24
  • 31
  • possible duplicate of [How to make a UITextField move up when keyboard is present](http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present) –  Jul 02 '15 at 08:34
  • User this http://stackoverflow.com/questions/7952762/xcode-ios5-move-uiview-up-when-keyboard-appears/26237038#26237038 – Kishore Suthar Jul 02 '15 at 08:34
  • Wellcome to iOS programming ! – ColdSteel Jul 02 '15 at 08:41
  • I would suggest to put your view inside scrollview and scroll it down as user progress by typing all that fields as well as allowing him to scroll with gestures. Thats what I usually do. – ColdSteel Jul 02 '15 at 08:42

1 Answers1

0

You can set notifications like this :

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)                                            name:UIKeyboardWillShowNotification object:self.view.window];

and also set notification to hide keyboard like this :

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:self.view.window];

and then call these functions and set any thing you want. Like move the view up animation when keyboard is shown and move the view down animation when keyboard hides. You can set these animations using function : animateWithDuration

Munahil
  • 2,256
  • 1
  • 14
  • 21
  • Using swift programming language? – Mehmet Jul 02 '15 at 08:48
  • 1
    [Swift version](http://stackoverflow.com/questions/28813339/move-a-view-up-only-when-the-keyboard-covers-an-input-field/28813720#28813720) (using UIScrollView) @Mehmet – Nerkyator Jul 02 '15 at 09:20