What's the UITableView index magnifying glass character?

前端 未结 11 1805
醉话见心
醉话见心 2020-12-12 10:09

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 assu

相关标签:
11条回答
  • 2020-12-12 10:42

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

    0 讨论(0)
  • 2020-12-12 10:46

    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:
    (source: booleanmagic.com)

    0 讨论(0)
  • 2020-12-12 10:50

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

    In Swift you would use UITableView.indexSearch.

    0 讨论(0)
  • 2020-12-12 10:54

    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];
    
    0 讨论(0)
  • 2020-12-12 10:57

    @"{search}" FTW.

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

    0 讨论(0)
  • 2020-12-12 11:00

    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.

    0 讨论(0)
提交回复
热议问题