Keyboard and the rest of the view

Discussion in 'iOS Programming' started by Nnavick, Feb 5, 2011.

  1. Nnavick macrumors regular

    Oct 13, 2010
    In the SMS app or other app that using a keyboard,
    When you press on the TextFiled the keyboard is
    coming up and the view same as the keyboard.
    My question is if this is a simple animation that change
    The view xcordinates or it's built in function?

    Thank you and have a nice weekend !
  2. dantastic macrumors 6502a


    Jan 21, 2011
    funny you should mention it, I just did that in a tableview for my app :)

    whateverCausedTheKeyboardToPopUp {
    	[UIView beginAnimations: @"anim" context: nil];
    	[UIView setAnimationBeginsFromCurrentState: YES];
    	[UIView setAnimationDuration: 0.3f];
    	[self.tableView setContentOffset:CGPointMake(0.0, [tableViewArray count] - 1 * 44)];
    	self.tableView.frame = CGRectOffset(self.tableView.frame, 0, -kKeyboardOffset);
    	[UIView commitAnimations];
    If you've a uiview with a textfield you may want to get rid of the setcontentoffset and change the self.tableview.frame to self.view.frame.

    don't forget to do a
     self.tableView.frame = CGRectOffset(self.tableView.frame, 0, kKeyboardOffset);
    when you're done with the keyboard.
  3. Nnavick thread starter macrumors regular

    Oct 13, 2010

    what value did you set for
  4. dantastic macrumors 6502a


    Jan 21, 2011
    It will depend on the type of keyboard and screen orientation.

    for my app a value of 215 does the trick.
  5. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    The height of the keyboard will vary with different orientations and maybe with different language keyboards. The height of the keyboard is sent in the notification posted when the keyboard appears. You should read it from there and use that value.

Share This Page