Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:42:42+00:00 2026-06-11T10:42:42+00:00

I have a UIScrollView which has several dynamic views inside of it, each of

  • 0

I have a UIScrollView which has several dynamic views inside of it, each of which has a text field. When I begin typing in one of the boxes, I want the scroll view to scroll so that the field is at the top of the screen (visible above the keyboard). It works great; here is the code:

(void)didStartTyping:(id)sender {
    [scrollView setContentOffset:CGPointMake(0, subView.frame.origin.y) animated:YES];
    scrollView.scrollEnabled = NO;
}

(void)didFinishTyping:(id)sender {
    scrollView.scrollEnabled = YES;
}

But, whenever the scroll view is scrolled up to the very top and I begin typing in the lowest visible text field, it doesn’t scroll down far enough (short by about 40 px). The puzzling thing is that it works if I scroll down just one pixel from the top of the scroll view, but when I scroll up to the top it behaves very differently.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:42:43+00:00Added an answer on June 11, 2026 at 10:42 am

    The best way i have managed to do this is to grab the keyboard frame, then update my scrollview insets when a text view gets textViewDidBeginEditing: called. Here im using a tableview, but the same logic should apply to a scrollview, the main difference being how you scroll. I use scrollToRowAtIndexPath, you will want to use scrollRectToVisible

    //setup keyboard callbacks
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWillShow:) 
                                                     name:UIKeyboardWillShowNotification 
                                                   object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWillShow:) 
                                                     name:UIKeyboardWillHideNotification 
                                                   object:nil];
    }
    
    - (void)keyboardWillShow:(NSNotification*)aNotification
    {
        NSDictionary* info = [aNotification userInfo];
        kbFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    }
    
    //this is called from your UITextViewDelegate when textViewDidBeginEditing: is called
    - (void)updateActiveTextScroll:(UITextView*)textView
    {
        activeTextView = textView;
        UIEdgeInsets inset;
        UIInterfaceOrientation orient = [[UIApplication sharedApplication] statusBarOrientation];
        if( UIInterfaceOrientationIsLandscape(orient) )
        {
            inset = UIEdgeInsetsMake(0.0, 0.0, kbFrame.size.width, 0.0);
        }
        else
        {
            inset = UIEdgeInsetsMake(0.0, 0.0, kbFrame.size.height, 0.0);
        }
        myTableView.contentInset = inset;
        myTableView.scrollIndicatorInsets = inset;
    
        [myTableView scrollToRowAtIndexPath:activeNSIndexPath
                           atScrollPosition:UITableViewScrollPositionBottom
                                   animated:YES];
    }
    
    //dont forget to reset when the keyboard goes away
    - (void)keyboardWillBeHidden:(NSNotification*)aNotification
    {
        UIEdgeInsets inset = UIEdgeInsetsZero;
        myTableView.contentInset = inset;
        myTableView.scrollIndicatorInsets = inset;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scroll view which has one UIView inside which contains the content.
I have a UIScrollView which has a subview UITextView. When I added text to
I have a UIScrollView which has an UIImageView in it. I need to be
I have a UIScrollView in which I am placing a bunch of views as
I have an Image inside UIScrollView which i can zoom in and out. I
I have subclassed UIView object inside a uiscrollview which displays a pdf page. I
I currently have a UIScrollView which has a content size equal to about 50
I have a UIViewController subclass which has the view property set to a UIScrollView
I have a UIControl type screen which has a fullscreen UIScrollView and UITextFields on
Right now I have an UIScrollView, which has a lot of UIImageViews, UILabels and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.