Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this, it is working for me</p> <pre><code>- (void)viewDidLoad [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } -(BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; return YES; } - (void)textFieldDidBeginEditing:(UITextField *)textField { activeField=textField; } -(void)keyboardWasShown:(NSNotification *)notification{ float viewWidth = 1024; float viewHeight = 654; NSDictionary *keyboardInfo = [notification userInfo]; CGSize keyboardSize = [[keyboardInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; float keyboardHeight = keyboardSize.width; CGRect viewableAreaFrame = CGRectMake(0.0, 0.0, viewWidth, viewHeight - keyboardHeight); CGRect txtDemoFrame = [activeField.superview convertRect:activeField.frame toView:self.view]; if (!CGRectContainsRect(viewableAreaFrame, txtDemoFrame)) { // We need to calculate the new Y offset point. //float scrollPointY = viewHeight - keyboardHeight; // Don't forget that the scroller should go to its original position // so store the current Y point of the content offset. self.originalScrollerOffsetY = self.SCRVMain.contentOffset.y; // Finally, scroll. [self.SCRVMain setContentOffset:CGPointMake(0.0, [activeField.superview convertPoint:activeField.frame.origin toView:self.view].y-200) animated:YES]; } } -(void)keyboardWillHide:(NSNotification *)notification{ UIEdgeInsets contentInsets = UIEdgeInsetsZero; self.SCRVMain.contentInset = contentInsets; self.SCRVMain.scrollIndicatorInsets = contentInsets; [self.SCRVMain setContentOffset:CGPointMake(0.0, self.originalScrollerOffsetY) animated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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