Help with adding index to list

Discussion in 'iOS Programming' started by boyplunder, Sep 12, 2008.

  1. boyplunder macrumors regular

    boyplunder

    Joined:
    Sep 8, 2008
    Location:
    UK
    #1
    I have a main tableview with a dictionary of words. I have been trying to learn how to add both a search field, which I've done ok with, and an index like the one down the side of contacts, which I haven't. This is now an obsession.

    I seem to be having a problem with setting up the array for the initial character, I think, and I'm not sure where I am going wrong.

    Does anyone have a really numbingly simple example I could appreciate?
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    I've done exactly this. You just need an array of strings of the letters that you want to show. The strings can actually be anything they don't have to be single letters. I build my array from my data so it's not generally applicable.

    Do you have the searchbar in the first table cell or outside the table?

    I have run into a problem where the search bar doesn't want to draw itself all the way across the table when the index is visible. The right edge of the search bar stays just to the left edge of the index. This leaves a white space under the index, which looks terrible. If you run into this or can solve it post here about it.

    The other problem with this is trying to place a magnifying glass at the top of the index. It seems that the contents of the array must be strings. I don't find a unicode character that represents a magnifying glass. So I can't figure out how contacts places a magnifying glass at the top of the index. Perhaps it's not a standard tableview and it draws the index itself, or they have a subclass of NSString that can draw an image.
     

Share This Page