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 7547127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:22:26+00:00 2026-05-30T09:22:26+00:00

I have a Scroll View, Table View, and textfield at the bottom which will

  • 0

I have a Scroll View, Table View, and textfield at the bottom which will trigger a keyboard show after clicked.
Table View is just a subview inside the Scroll view which to show some comments for that photos.

At the beginning, the tableView height shows correctly. However, after clicked any textField in the class, the tableView height changed. Anyone has solutions for this.

I have tested for the keyboard height. It will affect the additional height of the UITableView.
But I have no any ideas on how to keep the height the same as before the keyboard shows.

Please help.

Here is some codes,

//---when a TextField view begins editing---
-(BOOL) textFieldDidBeginEditing:(UITextField *)textFieldView {  
        currentTextField = textFieldView;

        return YES;
}  

-(BOOL) textFieldShouldReturn:(UITextField *) textFieldView {  
    [textFieldView resignFirstResponder];
    return NO;
}

//---when a TextField view is done editing---
-(void) textFieldDidEndEditing:(UITextField *) textFieldView {  
    currentTextField = nil;
}

//---when the keyboard appears---
-(void) keyboardDidShow:(NSNotification *) notification {
    if (keyboardIsShown) return;

    NSDictionary* info = [notification userInfo];

    //---obtain the size of the keyboard---
    NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGSize keyboardSize = [aValue CGRectValue].size;

    //---resize the scroll view (with keyboard)---
    CGRect viewFrame = [v_comment_editor frame];
    viewFrame.size.height -= keyboardSize.height;
    v_comment_editor.frame = viewFrame;

    //---scroll to the current text field---
    CGRect textFieldRect = [currentTextField frame];
    [v_comment_editor scrollRectToVisible:textFieldRect animated:YES];

    keyboardIsShown = YES;
}

//---when the keyboard disappears---
-(void) keyboardDidHide:(NSNotification *) notification {
    NSDictionary* info = [notification userInfo];

    //---obtain the size of the keyboard---
    NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGSize keyboardSize = [aValue CGRectValue].size;

    //---resize the scroll view back to the original size (without keyboard)---
    CGRect viewFrame = [v_comment_editor frame];
    viewFrame.size.height += keyboardSize.height;
    v_comment_editor.frame = viewFrame;

    keyboardIsShown = NO;
}

-(void) viewWillDisappear:(BOOL)animated {
    //---removes the notifications for keyboard---
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self 
     name:UIKeyboardWillShowNotification 
     object:nil];
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self 
     name:UIKeyboardWillHideNotification 
     object:nil];
}
  • 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-05-30T09:22:28+00:00Added an answer on May 30, 2026 at 9:22 am

    The code you show does resize the views when the keyboard is shown. It looks like it is supposed to return to the correct size when keyboard is hidden again.

    If you have trouble with one of the subviews, it is possible that it’s autoresize masks are set up in a weird way.

    The simplest way around it would be to have an instance variable in your handling class like:

    CGRect tableframe;
    

    and store the correct frame to it in the keyboarddidshow function, and restore the table to the original frame in ** keyboardDidHide** method.

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

Sidebar

Related Questions

I have a table view controller which doesn't let me manually scroll to the
I have an scroll view with some sophisticated animations happening during scrolling. Although after
In my table view I have to scroll to the top. But I cannot
I want to make a table view in which i want to show some
I have this really weird bug. When I scroll down my table view, down
I have a grouped table view with textfields in the tableview. For the keyboard
I have the following problem while i scroll the table view: NSCFString objectAtIndex:]: unrecognized
Possible Duplicate: Table View scroll when text field begin editing iphone I have loaded
i have photo gallery which loaded to scroll view vertically and i only want
I am designing an application in which i have a table view controller. Now

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.