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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:33:28+00:00 2026-05-12T19:33:28+00:00

I have a UITableView with an Index on the side; I want to add

  • 0

I have a UITableView with an Index on the side; I want to add a UISearchBar to it, but the index overlaps with the “x” to clear the search. I’ve noticed in the Contacts application, the textfield within the UISearchBar is resized to accommodate this, but I can’t work out how to do this in my own app.

I have tried the following in my viewDidLoad, but it does not seem to work.

UITextField * textField = (UITextField *)[[self.search subviews] objectAtIndex:0];
CGRect r = textField.frame;

[textField setFrame:CGRectMake(r.origin.x, r.origin.y, r.size.height, r.size.width-30)];

Any ideas?

  • 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-12T19:33:29+00:00Added an answer on May 12, 2026 at 7:33 pm

    it’s much easier than all these suggestions. In interface builder, instead of putting the Search Bar as the header of your Table View, you can put a View instead. Then, put a Navigation Bar inside this View. Grab the left resizing handle of the Navigation Bar and pull it to the right until the N B is only 25 pixels wide. Clear out the Title in the N B (double click to select it, then delete). Then, add a Search Bar into the same View. Move its right resizing handle to the left, adjust so that it abuts the N B. That’s it.

    You can enable a cancel button if you want too and it also won’t overlap the index (remains within the search bar).

    Apparently a Table View can only have 1 subview in its header, that’s why you need to put the View first, then the N B and Search Bar inside it.

    UPDATE: see Beginning iPhone Development from Apress, p. 241 of SDK 3 edition. You just disable the index while searching.

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
        if (isSearching) {
            return nil;
        }
        return keys;
    }
    

    Also they talk about adding a magnifying glass to the top of the index.

    Great book all around.

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

Sidebar

Related Questions

I want to implement index feature in UITableView as is in the standart contacts
I want to have selected index for UITableView . I have written following code:
So I have a UITableView that I'm using with Section Index Titles.. but I'm
Can I have that A-Z index bar in an UITableView also with UITableViewStyleGrouped, or
Does any one have tried to customize default section index displayed in UITableView. I
I have a UITableView displaying a list of Cities. I want to separate them
I have a UITableView with a UISearchBar at the top of it. I also
In a UITableView's index scroller (the scroller on the right side containing the chars
I have a UITableView that I want to scroll down and up without touching
I have UITableView with images as rows (cells). I use EGOImageView to load images

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.