views:

5255

answers:

11

In Apple's iPhone apps (like Contacts), they have a nice magnifying glass icon at the top of the table view index. Since the table view index API is character-based, I assume that this magnifying glass is a Unicode character. So far I've resorted to placing a question mark character there, but that looks lame.

Can anyone tell me what character the magnifying glass is?

A: 

Someone claims that Apple told them this isn't supported in the SDK.

carson
+1  A: 

You can certainly put a Unicode character in the table view index (I've done this with other characters) and put your header in the first table section in lieu of of the tableViewHeader. That said, I've yet to find the magnifying glass in any of the unicode references. The closes I've found is the Telephone Recorder symbol - ⌕ (\u2315). Unfortunately, it points in the wrong direction and the "handle" extends into the "magnifying glass."

Jablair
Yeah - I've been all through the characters and haven't seen it.My other thought is that it's in one of the font sets which lives on the iPhone and not in OS X.Lastly, perhaps it isn't a character at all; just some private icon Apple is swapping in internally.
David Grant
I grabbed a copy of Friend Book during the short time it was on the app store and it had a magnifying glass at the top of the index, which is why I assumed it was a Unicode character. But, like you said, I've yet to find it among any of the characters I've seen.
Jablair
A: 
rpetrich
+37  A: 

@"{search}" FTW.

Return that title and it's magically replaced by the correct glyph.

Holy crap, that's it! Thanks!
David Grant
i was searching it for the long and finally got it in the 2 years old forum... thanx.
Suriya
Consider using the `UITableViewIndexSearch` constant, as user123417 points out.
Adam Woś
A: 

I can understand why someone might not want to use the image, although it is very pretty... characters are so much easier to maintain and can scale with little effort.

⚦ is another unicode option for a magnifying lens-like glyph.. again it's not facing the correct direction.. I believe it's really some kind of hermaphroditic gender symbol. The html for the unicode symbol above is ⚦

I really think a magnifying lens symbol should be added to the unicode character set under "26: Misc. Symbols".

+21  A: 

Returning UITableViewIndexSearch as section index title (same as @"{search}") also works.

just to add, the docs note this is available in iPhone OS 3.0b and later.
hkatz
A: 

So this is all well and good. But what do you return for tableView:sectionForSectionIndexTitle:atIndex:? Returning 0 moves the table to the first section, but doesn't make the searchBar above the first section visible. -1 doesn't work either. I'm using a searchDisplayController. The search bar remains hidden "behind" the nav controller's title when you move to section 0.

dk
+1  A: 

the question is. if we use @"{search}";

will apple reject the app?

Sam Jarman
No. Use the UITableViewIndexSearch constant if you're concerned.
titaniumdecoy
+5  A: 

In tableView:sectionForSectionIndexTitle:AtIndex: explicitly scroll to the top and return NSNotFound:

- (NSInteger) tableView:(UITableView *)tableView
sectionForSectionIndexTitle:(NSString *)title
                atIndex:(NSInteger)index {
    if (index == 0) {
        [tableView setContentOffset:CGPointZero animated:NO];
        return NSNotFound;
    }
    return index;
}
Marcello Bastea-Forte
Another option is [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
Clint Harris
Thanks, this answer was very useful.
titaniumdecoy
A: 

i want to put the magnifying glass as an left overlay item into a text box? How would I use @"{search}" when textField.leftView expects an image?

Thanks!

David Hsu