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

  • Home
  • SEARCH
  • 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 8510413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:41:52+00:00 2026-06-11T03:41:52+00:00

I have uiscrollview, 2 textviewfields and I read all the posts about keyboard hiding

  • 0

I have uiscrollview, 2 textviewfields and I read all the posts about keyboard hiding textview and tried many methods, but still it hides it.

My code is like this:
ViewController.h

@property(nonatomic,retain) IBOutlet UITextView *campaignTitle;
@property (weak, nonatomic) IBOutlet UITextView *campaignDescription;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property UITextView *activeTextView;

ViewController.m

@synthesize campaignTitle;
@synthesize campaignDescription;
@synthesize scrollView;
@synthesize activeTextView;

#define SCROLLVIEW_CONTENT_HEIGHT 460
#define SCROLLVIEW_CONTENT_WIDTH  320

- (void)viewDidLoad
{
 [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWasShown:)
                                                 name:UIKeyboardDidShowNotification
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    scrollView.contentSize=CGSizeMake(0, self.view.frame.origin.y+self.view.frame.size.height+50);
    [super viewDidLoad];
}

- (BOOL) textViewShouldBeginEditing:(UITextView *)textView
{
    textView.text = @"";
    self.activeTextView = textView;
    return YES;
}

- (BOOL) textViewShouldEndEditing:(UITextView *)textView
{
     self.activeTextView = nil;
    return YES;
}

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if([text isEqualToString:@"\n"])
        [textView resignFirstResponder];
    return YES;
}

- (void)keyboardWasShown:(NSNotification *)notification
{   
    // Step 1: Get the size of the keyboard.
    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
    // Step 2: Adjust the bottom content inset of your scroll view by the keyboard height.
    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardSize.height, 0.0);
    scrollView.contentInset = contentInsets;
    scrollView.scrollIndicatorInsets = contentInsets;
    // Step 3: Scroll the target text field into view.
    CGRect aRect = self.view.frame;
    aRect.size.height -= keyboardSize.height;
    if (!CGRectContainsPoint(aRect, activeTextView.frame.origin) ) {
        CGPoint scrollPoint = CGPointMake(0.0, activeTextView.frame.origin.y - (keyboardSize.height-15));
        [scrollView setContentOffset:scrollPoint animated:YES];
    }
}

- (void) keyboardWillHide:(NSNotification *)notification {

    UIEdgeInsets contentInsets = UIEdgeInsetsZero;
    scrollView.contentInset = contentInsets;
    scrollView.scrollIndicatorInsets = contentInsets;
}

- (IBAction)dismissKeyboard:(id)sender
{
    [self.activeTextView resignFirstResponder];
}

There is delegation from the scroll view and campaignTitle, campaignDescription.

What is wrong? why the keyboard still hiding the bottom uitextview? The extra code that you may see is to support Return button in UITextView

  • 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-11T03:41:53+00:00Added an answer on June 11, 2026 at 3:41 am

    Make sure your UITextFields are actually inside of your UIScrollView inside your storyboard and not accidentally placed on the UIView below it.

    setContentOffset should do SOMETHING, even if it is not the intended effect. Since it seems to be doing nothing, I’d suspect that either your UITextFields are not subviews of it or your UIScrollView is not wired up in interface builder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIScrollView filled with subviews, all is well when creating it and
I have a UIScrollView which contains many UIImageView s, UILabels, etc... the labels are
I have a UIScrollView . The scrollview.contentSize is set to the height of all
I have a UIScrollView in my view control but my UIScrollView can't catch the
I have a UIScrollView with nested UIImageViews. Each imageview can zoom, but when I
I have a UIScrollView that shows vertical data, but where the horizontal component is
I have a UIScrollView . I'd like to do some animation with it, but
i have an uiscrollview and i add one by one uiimageviews but when i
I have an UIScrollView, that contains UIImageViews. All images keep their image ratio -
I have this UIScrollView inside another UIView, not occuping the entire area (all this

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.