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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:51:38+00:00 2026-06-05T23:51:38+00:00

I have a UIView — call it HomeView that contains a UITableView and a

  • 0

I have a UIView — call it HomeView that contains a UITableView and a UISearchBar. That is, they are subviews. These are added in viewDidLoad for HomeView. A picture is worth a thousand words:

enter image description here

enter image description here

As can be seen from these screenshots, the first item in the UITableView is hidden once the UISearchBar is displayed. Here is the relevant code:

- (void) viewDidLoad
  self.table_view = [UITableView.alloc.initWithFrame: self.view.bounds style:UITableViewStylePlain];
  self.table_view.bounds.origin.y += 44;
  self.table_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  // ^^^ This is the code I believe is one source of my problem



// Triggered when search button in nav bar is pressed

// code to calculate delta here

// Here's how the view is animated. The search bar frame
// is dropped down (works), and ideally, the tableview
// drops down exactly the same amount at the same time.
// If the action is to hide, then the inverse happens
// because +delta+ will have been calculated as a
// negative number above.
[UIView animateWithDuration: 0.7
  delay: 0.0
  options: UIViewAnimationOptionCurveEaseIn
  animations:^ {
    self.searchBar.frame = CGRectOffset(@searchBar.frame, 0.0, delta);
  }
  completion:^(BOOL finished){
    self.searchBarVisible = !self.searchBarVisible
    self.searchBar.hidden = !self.searchBarVisible
    edgeInsets = UIEdgeInsetsMake(0.0f, self.searchBarVisible ? delta : 0.0f, 0.0f, 0.0f)
    [tableView setContentInset: edgeInsets]
  }
];

What actually happens is that the search bar slides down as expected in response to the search button press and then slides up on next button press. However, the table view never adjusts.

The problem, as near as I can tell, is that in viewDidLoad, the enclosing HomeView has not been rendered, so the size is as-yet unknown. I can get the screen dimensions and use that, but I thought the auto resizing mask was better practice, right?

Are there obvious flaws in this, and is there a way to get the table view to animate down at the same time the search bar is?

Thanks

  • 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-05T23:51:40+00:00Added an answer on June 5, 2026 at 11:51 pm

    All right, let’s try this again!

    In your animation block, change the line where you make edgeInsets to:

    edgeInsets = UIEdgeInsetsMake(self.searchBarVisible ? delta : 0.0f, 0.0f, 0.0f, 0.0f);
    

    From what I can tell, the first argument is the top, and the one you had set was the left inset.

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

Sidebar

Related Questions

I have a UIView that contains your typical UITableView with a UISearchBar. It seems
I have a UIView that gets added to my UITableView .view as a subview.
I have a UIView in which I added a UITapGestureRecognizer . Inside that view
I have a UIView subclass that programmatically creates and adds a number of subviews.
I have a UIView that will need to display two UITableViews, but they are
I have a UIView that I am setting as the property of a UITableView
I have UIView designed in IB, and UITableView on it. In view contoller's viewDidLoad
I have a UIView that gets created and added as a subview dynamically, not
I have a UIView that contains a subview called menuView managed by a MenuViewController.
I have a UIView that a user can add subviews to. I now need

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.