iOS中的UITextView中没有显示笑脸(表情符号)? [英] Not showing smily ( Emoji ) in in UITextView in iOS?

查看:151
本文介绍了iOS中的UITextView中没有显示笑脸(表情符号)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将所有uni-code(表情符号字符)存储在iphone支持的plist中。当我直接写作

I have stored all uni-codes(emoji characters) in plist supported by iphone. When i write directly as

- (IBAction)sendButtonSelected:(id)sender {
NSMutableArray *emoticonsArray = [[NSMutableArray alloc]initWithObjects:@"\ue415",nil];
NSString *imageNameToPass = [NSString stringWithFormat:@"%@",[emoticonsArray objectAtIndex:0]];
NSLog(@"imageNameToPass1...%@",imageNameToPass);
messageTextView.text =imageNameToPass;
 }

它在textview中显示表情符号,但是只要我从plist中获取

it show emoji in textview but as soon as i fetch from plist

NSString *plistPath1 = [[NSBundle mainBundle] pathForResource:@"unicodes" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath1];
activeArray= [dictionary objectForKey:categoryString];

NSLog(@"activeArray...%@",activeArray);

emoticonsArrayForHomeEmoji = [[NSMutableArray alloc]initWithCapacity:[activeArray count]];
for(int i=0; i<[activeArray count]; i++)
{
    id objects = (id)[activeArray objectAtIndex:i];
    [emoticonsArrayForHomeEmoji insertObject:objects atIndex:i];
}
NSString *imageNameToPass = [NSString stringWithFormat:@"%@",[emoticonsArrayForHomeEmoji 
objectAtIndex:0]];
NSLog(@"imageNameToPass1...%@",imageNameToPass);
messageTextView.text =imageNameToPass;

然后它在文本视图中将unicode显示为text \\\而不是表情符号。

then it shows unicode as text \ue415 in text view instead of emoji.

我做错了什么?请帮帮我!

What i am doing wrong?. Please help me out!

推荐答案

\uxxxx 表示法仅由编译器解释(因为源代码通常是ASCII或MacRoman或其他任何但不常见的UTF8)

The \uxxxx notation is only interpreted by the compiler (as the source code is usually in ASCII or MacRoman or whatever but not often UTF8)

Plist文件直接使用这些字符,并以UTF8编码。
因此,您应该直接将表情符号字符本身插入plist,而不是使用 \uxxxx 表示法,因为Plist数据将按原样读取。

Plist files uses the characters directly, and are encoded in UTF8. So you should insert the emoji character itself into the plist directly, instead of using the \uxxxx notation, as the Plist data will be read as-is.

Lion and Mountain Lion 键盘调色板直接包含表情符号字符,因此在编辑PLIST时插入字符应该不难。

Lion and Mountain Lion Keyboard palettes contains emoji characters directly, so that should not be difficult to insert the characters when editing the PLIST anyway.

这篇关于iOS中的UITextView中没有显示笑脸(表情符号)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆