Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try this code.......</p> <pre><code> -(void)setViewMovedUp:(BOOL)movedUp { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // if you want to slide up the view CGRect rect = self.view.frame; if (movedUp) { rect.origin.y -= moveKeyboard; } else { rect.origin.y += moveKeyboard; } self.view.frame = rect; [UIView commitAnimations]; } -(void)keyboardWillShow { // Animate the current view out of the way if (self.view.frame.origin.y &gt;= 0) { [self setViewMovedUp:YES]; } else if (self.view.frame.origin.y &lt; 0) { [self setViewMovedUp:NO]; } } -(void)keyboardWillHide { if (self.view.frame.origin.y &gt;= 0) { [self setViewMovedUp:YES]; } else if (self.view.frame.origin.y &lt; 0) { [self setViewMovedUp:NO]; } } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // register for keyboard notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // unregister for keyboard notifications while not visible. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; } </code></pre> <p>Edit: moveKeyboard is float. Set its value according to your need.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload