Question

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?

Was it helpful?

Solution

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

OTHER TIPS

@"{search}" FTW.

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

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;
}

There already is an existing UTF codepoint for the magnifying glass. It is U+1F50D. However it's slightly tricky getting Xcode to recognize this number. According to Apple's String Programming Guide the UTF bits should be split into two UTF-16 surrogate pairs (0xD83D, 0xDD0D). Check with this surrogate pair calculator for reference.

An NSString instance with the contents of the surrogate pair can be obtained with:

[NSString stringWithFormat:@"%C%C", 0xD83D, 0xDD0D];

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."

In the sectionIndexTitlesForTableView add a NSMutableArray* titles for example and in addition to your indexes add the [titles addObject: UITableViewIndexSearch]

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

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".

I know this is an old post but since it's similarly related to what I was looking for... If anyone is looking for the Unicode Character of the magnifying glass, it would be this one \u128269 represented by this: 🔍 that is if your browser is displaying unicode

You can view the full detail of it on this web site: http://www.charbase.com/1f50d-unicode-left-pointing-magnifying-glass

In my case I wanted to do a search input box with the magnifying glass in it, I manage to do it via this piece of code, please note that we need to use a special font that might not work in older browser or OS:

<input type="text" style="font-family: Segoe UI Symbol;" placeholder="&#128269;">

This works on my machine Win7 in both Firefox and Chrome but IE is always an exception with placeholder in this case.

You could use a space as the character for the index and then overlay an UIImageView that has user interaction disabled and contains the following image: Search Icon
(source: booleanmagic.com)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top