What's the UITableView index magnifying glass character? - iphone

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?

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

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

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="🔍">
This works on my machine Win7 in both Firefox and Chrome but IE is always an exception with placeholder in this case.

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

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)

Related

Objective c - Text indentation

This question is about implementing text indentation ("The placement of text farther to the right to separate it from surrounding text") in iOS.
Take for example the following text:
This is the first section.
This is the second one,
with two lines.
This is the third.
Notice that the second row in section 2 begin farther to the right and just below the line above.
My code contains an array of NSString, each one should be display as a section with numeric bullet like above. for example:
NSArray *array = [NSArray arrayWithObjects:#"1. This is the first section.", #"2. This is the second one, with two lines.", #"3. This is the third.", nil];
I use UILable to display the text on screen.
To set the text from the array to the label, and to separate each string in a new line I use
myLabel.text = [array componentsJoinedByString:#"\n"];
Any ideas how to get this effect?
This is possible to some degree in iOS6 with - [UILabel setAttributedText:].
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.headIndent = 29;
myLabel.attributedText = [[NSAttributedString alloc] initWithString:
#"1.\tShort line.\n2.\tLong line with content that triggers wrapping.\n3.\tShort line."
attributes:#{NSParagraphStyleAttributeName: paragraphStyle}];
This adds indentation to the subsequent lines. It looks like iOS doesn't support tab stops in the same way as OSX so I'm not seeing a way to adjust the gap between the number and the text. This is probably possible in CoreText.
Of course, you could also just replace the label with a UIWebView and have full formatting control on all versions of iOS at the cost of performance.
Well I decided to implement it my self without using Core Text, I just created a view strcture that make all the indentation work by itself, and let you customize it as you want.
For all of you interested in the implementation, you can see the source code and an example project here:
ECListView Project
UILabel is not going to cut it if you have any kind of specific layout requirements. For that, you're going to need to dig into Core Text. The good news is that Core Text will let you do any kind of text layout you can imagine. The bad news is that all that power brings with it some complexity, so to use it you're going to have to invest some time learning how the framework works.
An alternative that's suitable in some situations is to use a web view to display your text. UIWebView will let you do whatever text layout you can manage using HTML and CSS.

PPTX - Finding out whether text is bulleted from OpenXML

I have not been able to find any indicator which could tell me whether text in txBody tag is bulleted or not, can you please me in identifying which indicator should I use to understand whether the text is bulleted or plain ?
-Thank you
Inside the txBody tag, you can look for the tags "a:buFont" and "buChar" which helps you identify that the text is bulleted. eg.
<a:buFont typeface="Arial" pitchFamily="34" charset="0"/>
<a:buChar char="•"/>
Update:
Hi, +1 For posting this question, learnt a lot from it.
After googling I found this link which addresses similar issue, the resoponse from Adamm clears this,
"Ok, so i think ive got this figured out. Basically if no formatting
is specified in the layout or the slide, it goes to the master, and if
its a 'title' or 'ctrTitle' shape it uses the formatting in
and it defaults to lvl1. Same goes for text that is not
in a title shape, for these it defaults to the formatting in
and if no lvl is specified it defaults to lvl1. And
another piece of advice, although not pertinent to my original
question, there is another txStyle in the slideMaster,
which is used for text in a shape that is not in a txBody."
Now the slide in your pptx is using "Office Theme" and the text you are interested in is in the format shape within the slide design. The bulletted text is inheriting from the slideMaster1.xml in SlideMasters.
As mentioned in the above quote the buletted text is getting inherited from "a:lvl1pPr" of "p:bodyStyle" in the slideMaster1.xml, also you can see the level 2 bullet is defaulted to "-" for the office Theme slide master there.
I tried to confirm this by changing the char = "•" to ">" to see the bulleting changed to ">" in the below line
<p:bodyStyle>
<a:lvl1pPr marL="342900" indent="-342900" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000"/>
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0"/>
<a:buChar char="•"/>
....
Now if you want to change it programatically you can do this from slide master 1. But the only problem here is When we change the bulletted style here(like above), it is changing for all the slides and also for the future slides you will be creating with the same theme within your ppt.
Hope this helps.
Regards.

Overriding Emoji Graphics

I want to override the emoji icons with my own custom graphics (only within my app).
From what I've read so far, one possible solution is to create a custom font extension which overrides the desired unicode characters. Preferable I would like to maintain inter-operability with CATextLayer.
Edit: Looks like custom fonts won't be my solution; fonts must be defined in gray-scale. Next possibility: Creating a custom CALayer, chunking the string into segments based on emoji code, and doing the type setting + graphics rendering manually (i.e. with core graphics and core text)
Edit: Also looking to maintain smooth scrolling performance in a table views.
I have devoted a lot of time trying to do the same. Your best bet is to replace the unicode values for the emoji in your NSString eg. \uE100 etc. with a placeholder string. You could replace the emoji encodings with an HTML Tag and use either UIWenViews or DTCoreText to draw the image inline.
I have done this, it works too, but it will be a little slow (Specially if you want to display this Label in table views.)
Here is a little starter:
Make a dictionary with UIImages as objects and placeholder strings as keys:
self.emoticonDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:#"happyEmoticon.png", #":)",
#"sadEmoticon.png", #":(",
#"testImg.png", #"\uE100",
nil];
__block NSString *text1 = [NSString stringWithFormat:#"<html><p>%#</p></html>",text];
[self.emoticonDict enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
text1 = [text1 stringByReplacingOccurrencesOfString:key withString:[NSString stringWithFormat:#"<img height= 15 width= 15 src=\"%#\">",obj]];
}];
You can at this point load this HTML into a UIWebView and you will have what you want.
[myWebView loadData:_htmlData MIMEType:#"text/html" textEncodingName:#"utf-8" baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];//do create the webview first
If the slow speed of a UIWebView is a concern, you can read ahead. In either case do look at the note towards the end of this answer.
To create a DTAttributedLabel, we do the following:
First we build a NSattributedString using the DTHTMLAttributedStringBuilder:
NSAttributedString *temp = [[[DTHTMLAttributedStringBuilder alloc] initWithHTML:text1
options:#{
DTDefaultFontFamily: #"Helvetica",
DTDefaultFontSize:#15,};
documentAttributes:nil]
generatedAttributedString];
Then you can use a DTAttributedLabel instance to display temp.
self.tempLabel.attributedString = temp;//create a DTAttributedLabel Instance called tempLabel before this, I had it as a property
My objective was to generate text label's really fast (Table Views) while supporting custom emoticons. DTAttributedLabels are fast (much faster than a UIWebView)
NOTE:
I also made a custom font where I had mapped the unicode values for the emojis to a custom glyph. To my surprise, still the default emojis were displayed. I would like to claim here that whenever iOS (CoreText) comes across a character whose value lies in the Emoji section, it draws it using the AppleColorEmoji font by default. The lack of documentation on how Apple Color Emoji font is actually drawn on iOS actually makes it difficult for me to prove this, but this seems to be a plausible explanation.
If you drop an emoji from the character palette app onto a file in textEdit, then select it and try to change the font, you see that it doesn't happen.
Similarly, if you type some text, then select it and try to change it's font to Apple Color Emoji, you'll see it doesn't happen. When I decompiled the Apple Color Emoji font, I didn't find character mappings or glyphs for textual characters (except 0-9). Somehow, even if you set a label's font as Apple Color Emoji, the font for the textual (non-emoji) part of your label's text is set to something else.
Kindly feel free to comment and share your knowledge since this region around the Apple Color Emoji font still remains very unclear.
One solution would be to use the UITextField or TextView delegate and listen to the user's input. When they type an emoji character, pop in a UIImageView inline with the text, and delete the emoji icon with the input.
There's a few mentions of this issue on Apple's private devforums (which you have access to if you're a registered member of the iOS developer program).
It sounds like the potential solution would be to explicitly set the font for whatever you're trying to display.

Non-Alphabetical Index for UITableView

How does one implement a NON alphabetical index for a UITableView? An example of this can be seen in Apple's Remote App. When looking at songs, there is a dotted index on the right hand side that allows the user to scroll quickly through the entire table. There are also no section headers.
Thanks
I'd guess that it works by returning an array full of the “middle dot” character (Unicode 00B7), bookended by the “bullet” character (2022). In the Remote app, the index has 23 items in it; therefore, to do this, you need to split up your data into 23 sections of roughly equal length. As occulus says, returning nil or #"" in -tableView:titleForHeaderInSection: will cause no section headers to be shown.
Return the aforementioned array of characters in your data source’s -sectionIndexTitlesForTableView: method, then implement -tableView:sectionForSectionIndexTitle:atIndex: to return the section index it gives you, and you should get identical behavior to Remote’s.
If you specify #"" for a section title, the section header won't be shown, which will give you the effect you desire. To use table indexing (the right hand side tiny list), you should still organise your table in sections so it knows where to jump when a index is touched, you just have to hide the section titles as I described.
To add index items, see UITableViewDelegate's method:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

Numeric keyboard with decimal separator

How can I get the numeric keyboard with the decimal separator? Currently I am stuck with UIKeyboardNumberPad.
you can try this
UIKeyboardTypeDecimalPad
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter,
UIKeyboardTypeWebSearch,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable // Deprecated
} UIKeyboardType;
If you don't like those, you can always modify them in code...
http://openradar.appspot.com/6635276
This has a solution:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/6573-howto-customize-uikeyboard.html
The UIKeyboardTypeNumbersAndPunctuation is probably the least-bad option, unless you have the time and resources to roll your own keyboard.
The iPhone SDK currently does not offer a keypad (0-9) + decimal button UIKeyboard. I suspect this was designed because for the majority of use cases, it is not needed.
See this previous StackOverflow question discussing the (lack of) need for a decimal separator for currency inputs. I also wrote a blog post about this very topic.
However, if you really do need a keypad + decimal button keyboard, your only option will be to roll your own custom keyboard. Contrary sbwoodside's answer, you really want to shy away from customizing the existing UIKeyboard. While this may be easy to do, it relies upon private classes that can change anytime...meaning your hack could break in the future without warning.