Returning UITableViewIndexSearch
as section index title (same as @"{search}") also works.
In Swift you would use UITableView.indexSearch
.
@"{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];
A constant UITableViewIndexSearch is used in the case, as noted here:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Section_Index_Icons
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."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With