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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:34:42+00:00 2026-05-26T19:34:42+00:00

I have a custom UIViewController inited from a nib file with the following view

  • 0

I have a custom UIViewController inited from a nib file with the following view hierarchy:

Nib

…where on the left side orange area is a “header view” with two UIButtons and an UILabel at the center and blue area is an UITableView; all under a single UIView.

At run–time this would render more or less like below:

Render

At this point, whenever user will tap on the search bar, I would expect hiding both navigation bar and header view with search bar moved to the top of the window.

However this isn’t the case, because navigation bar will automatically will get out of the window and the header view will move to top, but still will stay in the scene; rest will stick to their original places.

At this point I had to add the following code in order to move header view out of the window:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.2];

    CGRect frame = self.headerView.frame;
    frame.origin.y -= frame.size.height;
    self.headerView.frame = frame;

    [UIView commitAnimations];
}

which will result to:

Search

… As you may have already noticed header view will move just fine, but the search bar will stick to its original position.

I tried to reposition both self.view or search table view, but no luck there.

What should I do? 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-05-26T19:34:43+00:00Added an answer on May 26, 2026 at 7:34 pm

    Make sure you implement searchDisplayControllerWillBeginSearch: and searchDisplayControllerWillEndSearch: of UISearchDisplayDelegate and use something similar to:

    [UIView beginAnimations:nil context:NULL];
    
    CGRect headerViewFrame = self.headerView.frame;
    headerViewFrame.origin.y -= 44.0f;
    self.headerView.frame = headerViewFrame;
    
    CGRect tableViewFrame = self.tableView.frame;
    tableViewFrame.origin.y -= 44.0f;
    self.tableView.frame = tableViewFrame;
    
    [UIView commitAnimations];
    

    and

    [UIView beginAnimations:nil context:NULL];
    
    CGRect headerViewFrame = self.headerView.frame;
    headerViewFrame.origin.y += 44.0f;
    self.headerView.frame = headerViewFrame;
    
    CGRect tableViewFrame = self.tableView.frame;
    tableViewFrame.origin.y += 44.0f;
    self.tableView.frame = tableViewFrame;
    
    [UIView commitAnimations];
    

    … accordingly.

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

Sidebar

Related Questions

I have a custom UIViewController and a corresponding view in a nib file. The
I have a custom UIViewController subclass that handles all the view initialization by itself
I have a UITableView , which I am controlling from a custom UIViewController .
I have a storyboard with a UIViewController. Inside this view, I've placed a custom
I have a custom UIView which gets loaded through a NIB inside a UIViewController.
I have a custom view MyView : UIViewController <UITableViewDelegate, UITableViewDataSource> with a UITableView within
I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with
I have a custom UIViewController and custom UIView. I'd like to override the viewcontroller.view
I have this a simple question: How do I resize a UIViewController's view from
I have a custom UIViewController subclass, which gets pushed on a UINavigationController stack. I

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.