Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

boyplunder

macrumors regular
Original poster
Sep 8, 2008
165
0
UK
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?
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.