iPhone Emoji Decimal Value Representation - iphone

I want to display an Emoji icon using it's decimal value, for example &#xe41e
How can I display it in an UILabel ?
Thanks!

Try this
textLabel.text = #"\ue41e";
Instead of &#x, use \u. I hope this is the one you want.

Related

Display what AVSpeechSynthesizer is showing as subtitles with Swift

I have an array with quotations, and am using a button to start a random quotation playing from the array.
I'm wondering, how would I have the selected random quotation also displayed in the ViewController so that people can read what the speechsynthesizer is reading?
How would I have the selected random quotation also displayed in the ViewController so that people can read what the speechsynthesizer is reading?
The best way to highlight the vocalized word is using the speechSynthesizer:willSpeakRangeOfSpeechString:utterance: method of the AVSpeechSynthesizerDelegate protocol.
Instead of copying and pasting the code snippet here, take a look at this complete and useful example (ObjC and Swift) that displays the vocalized word in a bold font with the speech synthesis.
...is there some way of using Subtitles.sizeToFit() so that the Label is split into 3 or more rows, instead of just "one row till infinity"?
In the Xcode Interface Builder - Attributes Inspector, set the value of the label property Lines to 0 and adapt your constraints to get a multiline presentation.
Add a label to your view and and set the quote text to it
quoteLabel.text = randomQuote
To show your label on multiple rows add:
label.numberOfLines = 0

how to set the bold in part of the text in UILabel

I am new in iPhone application development. How to set the bold in part of the text in UILabel.
Example:
Step 1- Separate all parts of the plant (stem, roots, leaves, flower etc..)
Step 2- Only test one part at a time
I need like example in UILabel
Thanks in advance
Implement TTTAttributedLabel or OHAttributedLabel and use:
NSMutableAttributedString *theText = theLabel.text;
[theText applyFontTraits:NSBoldFontMask range:NSMakeRange(0,[text length])];
theLabel.text = theText;
to bold specific parts of the string (change the NSRange as required).
For now, you're going to have to use a third party component, since there's no attributed string support in UILabel.
Try https://github.com/mattt/TTTAttributedLabel/
In order of increasing complexity, here's some other solutions:
Alternatively, use a WebView with HTML.
Alternatively, use a CATextLayer, this is only slightly more work than adding a UILabel, but you need a little understanding of how layers work vs. views.
Alternatively, draw your strings yourself using CoreText.

iPhone: Phone Number UITextView vs UILabel

I have a UITableView. In row I need to setup text, so I need to use UILabel or UITextView. I need to detect phone number in text, so I use UITextView. BUT I need to set text only in 2 lines and if it's longer, setup ellipses in the end , because row height isn't big, so that work UILabel do perfect. So how to be ??? Can UILabel detect phone number ? or can i set UITextView in 2 lines and set ellipses in the end ?? Thanks...
I do not think that the UITextView has a property that let you set ellipses at the end if the text is to long. However that is simple to fix:
NSString documentation
You could use this method if all you want to do is to allow let say 120 characters, and starting from 0.
substringToIndex:
Returns a new string containing the
characters of the receiver up to, but
not including, the one at a given
index.
(NSString *)substringToIndex:(NSUInteger)anIndex
NSString *shortText =
[[someLongTextVariable substringToIndex: 120] stringWithString:#"..."];
Maybe you should use a mutable string for this, I do not know what performes the best. But if you do this, you could atleast detect phone numbers.

Custom iPad 10-key popover possible

and thanks for your responses in advance.
I have been looking around for the possibility of having a 10-key, numeric only, input available when a user clicks on certain fields that do not require the use of the full size keyboard.
I know that popovers can properly display custom types of input, but does anyone know if there is a way for a standard 10-keypad to display in a popover? And if so, can you point me in the right direction.
Again, thanks in advance.
-Rick
You don't need to use popover if you try to enter numeric value in a UITextField/UITextView.
You can replace the keyboard by your own view.
You just do :
[yourTextField setInputView:myInputView];
You can have a look at KeyboardAccessory sample from apple
http://developer.apple.com/iphone/library/samplecode/KeyboardAccessory/Introduction/Intro.html
In this example, they provide an accessory view to the input view but if you modify the code and set inputView instead of inputViewAccessory, you should be able to do what you need.
If you use a UITextView, you can append text where the carret is with the following code:
NSMutableString *text = [textView.text mutableCopy];
NSRange selectedRange = textView.selectedRange;
[text replaceCharactersInRange:selectedRange withString:#"\n"];
textView.text = text;
If you use a UITextField, it seems you can only append text at the end of the string (no mean to retrieve carret position).

How to get the same UITableViewCell layout as in the Address Book app?

I currently have a custom UITableViewCell which contains a few labels, and an image.
The "main" label is used to display people's names. Currently, I'm styling it in bold text.
What I'd like to do (to gain some space and readability), is to mimic the Address Book app cell style, that is: first name in light text, and family name in bold text.
Is there a way to do this using the same UILabel? Or, should I use 2 different UILabels? How should I layout them, without knowing their sizes?
Thanks in advance for your assistance!
See this sample code from atebits:
http://atebits.cachefly.net/blog/FastScrolling/FastScrolling.zip
It does something similar to what you want.
You can use the built-in UITableViewCellStyleValue2. From the UITableViewCell.h header file:
UITableViewCellStyleValue2, // Right aligned label on left with blue
//text and left aligned label on right (Used in Phone/Contacts)
Pass this into your [[UITableViewCell alloc] initWithStyle:...] method.
I think it's table view cell with UITableViewCellStyleDefault style. If you'd like to use different font attributes then you need to use different labels (because there is no attributed strings yet). To calculate size of these labels you should use following method:
- (CGSize)sizeWithFont:(UIFont *)font minFontSize:(CGFloat)minFontSize actualFontSize:(CGFloat *)actualFontSize forWidth:(CGFloat)width lineBreakMode:(UILineBreakMode)lineBreakMode;
or any relevant from NSString(UIStringDrawing).
Also, you can use custom strings drawing instead of UILabel.