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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:23:53+00:00 2026-06-11T14:23:53+00:00

I have standard iPad view controller which has a custom navigation bar at the

  • 0

I have standard iPad view controller which has a custom navigation bar at the top. In the xib-file I’ve added a UISearchBar aligned to the right edge of the view. The search bar is 320px in width. I init a searchdisplaycontroller like this:

// Search display controller
self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar 
                                                                                contentsController:self];
_mySearchDisplayController.delegate = self;
_mySearchDisplayController.searchResultsDataSource = self;
_mySearchDisplayController.searchResultsDelegate = self;

The problem is that when I press the search bar, the bar resizes to be the full width of the entire view, but keeps its x-position. This means that it stretches far outside the screen. I’m guessing it has something to do with the “Cancel” button that slides in next to a search bar. If I place the search bar to the far left in the screen, it animates to the full width of the screen and the cancel button is visible.

Anyone has a solution for this?

  • 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-11T14:23:54+00:00Added an answer on June 11, 2026 at 2:23 pm

    You can animate the frame of your UISearchBar in the searchDisplayControllerWillBeginSearch method to correct its position like this:

    - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
    {
        // animate the search bar to the left ie. x=0
        [UIView animateWithDuration:0.25f animations:^{
            CGRect frame = controller.searchBar.frame;
            frame.origin.x = 0;
            controller.searchBar.frame = frame;
        }];
        // remove all toolbar items if you need to
        [self.toolbar setItems:nil animated:YES];
    }
    

    and the animate it back again when finished searching:

    - (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
    {
        // animate search bar back to its previous position and size
        // in my case it was x=55, y=1
        // and reduce its width by the amount moved, again 55px
        [UIView animateWithDuration:0.25f 
                              delay:0.0f
                        // the UIViewAnimationOptionLayoutSubviews is IMPORTANT,
                        // otherwise you get no animation
                        // but some kind of snap-back movement 
                            options:UIViewAnimationOptionLayoutSubviews 
                         animations:^{
                             CGRect frame = self.toolbar.frame;
                             frame.origin.y = 1;
                             frame.origin.x = 55;
                             frame.size.width -= 55;
                             controller.searchBar.frame = frame;
                         } 
                         completion:^(BOOL finished){
                             // when finished, insert any tool bar items you had
                             [self.toolbar setItems:[NSArray arrayWithObjects: /* put your bar button items here */] animated:YES];
                         }];
    }
    

    I have answered a similar question, you can check it here, I’ve put some images too.

    The only thing you have to do is to adapt the code for the iPad.

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

Sidebar

Related Questions

I have a navigation controller in the master pane of a split view controller.
I am working on an iPad app with a split view controller. I have
I have a web app which has standard things for learning based app like
Ive got an iPhone/iPad universal application and I wanted to have a custom navigation
I have standard source code package under Linux which requires to run ./configure make
Is it possible to have standard war deployment, which can be deployed on tomcat
I have a standard list view setup with backbone that looks something like below.
I have a standard text input that has a blur event. The blur event
I have an opengl game for iPhone/iPad (universal). I added the ability to send
I have taken a project based on the standard iPad SplitViewerController template and implemented

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.