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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:35:44+00:00 2026-05-14T00:35:44+00:00

I can’t seem to get a UISearchBar to position itself from the far left

  • 0

I can’t seem to get a UISearchBar to position itself from the far left to the far right in the navigation bar. In the -(void)viewDidLoad method, I have the following code:

UISearchBar *sb = [[UISearchBar alloc] initWithFrame:self.tableView.tableHeaderView.frame];
sb.delegate = self;
self.navigationItem.titleView = sb;
[sb sizeToFit];
[sb release];

When you build and run, it looks just fine at first glance. However, looking more closely, you can tell there is a margin/space on the left. This wouldn’t be a big deal in the grand scheme of things, but when I tap the search bar to start a search, I animate the cancel button into view. Because the search bar is positioned slightly to the right, the animation is jerky and the cancel button falls off the end like so:
link text

It seems as if the UINavigationItem is like a table with three cells, where there is a padding on the first and last which I can’t remove – nor does there seem to be a way to ‘merge’ it all together and then place the search bar there. I know this look is possible, because the AppStore search has a search bar in the navigation bar and it goes all the way to the edges. Anyone know how to get the search bar to go all the way to the edges so my slide-in cancel button animation will work properly?

  • 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-14T00:35:45+00:00Added an answer on May 14, 2026 at 12:35 am

    I think I found out the answer – though I haven’t tested to verify. In the issue I provided above, I have the following structure:

    tab bar controller -> navigation controller -> view controller(s)

    The search bar in question was in a view controller, which in turn was in the navigation controller, which navigation controller is in the tab bar.

    I was casually watching the Stanford CS 193P (Spring 2009) courses and at the end of Lecture 13, the answer may have been presented. Alan Cannistraro stated that the structure of the Presence app should have this structure:

    this structure http://img143.imageshack.us/img143/6/viewcontrollerstructure.jpg

    where the bottom view controller (adjacent to the tab bar controller) was the view controller which had the search bar control. He warned if it’s not done in this fashion, you’ll “run into problems”. Possibly the problem I faced? I believe so.

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

Sidebar

Related Questions

Can we add multiple rows in the database table from one JSF page in
Can someone point me to good resource for Net::HTTP? I'm trying to understand why
Can anyone please tell me how to check whether the entered amount (Indian currency)
Can anyone point me out or explain what is the difference between android Home
Can you reorder SQLite table columns via a query? I would prefer a query
Can anyone verify my dealloc method is correct? Since my titleLabel and checkImageView are
can I change background color for disabled <h:inputText> ? I've tried to do this
Can somebody recommend the best (and preferably portable) way to render HTML documents onto
Can anyone recommend whether I should do something like: os = new GzipOutputStream(new BufferedOutputStream(...));
Can you post a regex search and replacement in php for minifying/compressing javascript? For

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.