I am tryingt o build an application where I am giving user liberty to add the emojis as in GTalk (e.g. :P :) :( ...). But I am not able to figure out the exact way to handle and display them once the characters are entered by the user.
Kindly pour in ideas for the same, as any form of help could trigger a solution for this.
For inputs you can use custom buttons, setting their titles with the unicode representation of the emojis. Iphone has native support for this.
[myButton setTitle:@"\ue415" forState:UIControlStateNormal];
For display it in a textbox you have to handle this as a single char of a string so you can concatenate your regular text with emojis.
A complete list of emojis are listed in this page: http://pukupi.com/post/1964/
Edit: You can use a conversion table
:) = \ue415 :( = \ue40e ....
You can use that conversion table with using images instead unicode chars but it is very complicated if you want to merge text and images in the same paragraph. Here is an example using a property list if you want to use images
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SparkSetVersion</key>
<integer>1</integer>
<key>Emoticons</key>
<dict>
<key>angry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>>:o</string>
<string>>:-o</string>
<string>>:O</string>
<string>>:-O</string>
<string></string>
</array>
<key>Name</key>
<string>Angry</string>
</dict>
<key>blush.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-[</string>
</array>
<key>Name</key>
<string>Blush</string>
</dict>
<key>confused.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>?:|</string>
</array>
<key>Name</key>
<string>Confused</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>B-)</string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>cry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:'(</string>
<string></string>
</array>
<key>Name</key>
<string>Cry</string>
</dict>
<key>devil.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>]:)</string>
</array>
<key>Name</key>
<string>Devil</string>
</dict>
<key>grin.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-D</string>
<string>:D</string>
<string></string>
</array>
<key>Name</key>
<string>Grin</string>
</dict>
<key>happy.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
</array>
<key>Name</key>
<string>Happy</string>
</dict>
<key>laugh.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:^0</string>
</array>
<key>Name</key>
<string>Laugh</string>
</dict>
<key>love.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:x</string>
</array>
<key>Name</key>
<string>Love</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>sad.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-(</string>
<string>:(</string>
<string></string>
</array>
<key>Name</key>
<string>Sad</string>
</dict>
<key>smile.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
<string>:)</string>
<string></string>
</array>
<key>Name</key>
<string>Smile</string>
</dict>
<key>silly.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-p</string>
<string>:-P</string>
<string>:P</string>
<string>:p</string>
<string></string>
</array>
<key>Name</key>
<string>Tongue</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>8-)</string>
<string></string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>wink.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;-)</string>
<string>;)</string>
<string></string>
</array>
<key>Name</key>
<string>Wink</string>
</dict>
</dict>
</dict>
</plist>
来源:https://stackoverflow.com/questions/5659935/implement-emoticons-in-xcode