static NSString *const deleteButtonId = @"DeleteButtonId";//删除按钮的标志
#define EMOJI_CODE_TO_SYMBOL(x) ((((0x808080F0 | (x & 0x3F000) >> 4) | (x & 0xFC0) << 10) | (x & 0x1C0000) << 18) | (x & 0x3F) << 24);
_defaultEmoticons = [NSMutableArray array];
for (int i=0x1F600; i<=0x1F64F; i++)
{
if (i < 0x1F641 || i > 0x1F644)
{
int sym = EMOJI_CODE_TO_SYMBOL(i);
NSString *emoT = [[NSString alloc] initWithBytes:&sym length:sizeof(sym) encoding:NSUTF8StringEncoding];
[_defaultEmoticons addObject:emoT];
}
}
for (NSInteger i = 0;i < _defaultEmoticons.count;i ++)
{
if (i == 20 || i == 41 || i == 62 || i == 83)
{
[_defaultEmoticons insertObject:deleteButtonId atIndex:i];
}
}
if (self.defaultEmoticons.count % 21 != 0)
{
for (NSInteger i = self.defaultEmoticons.count; i < self.defaultEmoticons.count + 21; i ++)
{
[self.defaultEmoticons addObject:@""];
if (self.defaultEmoticons.count % 21 == 0)
{
break;
}
}
}
[self.defaultEmoticons replaceObjectAtIndex:self.defaultEmoticons.count - 1 withObject:deleteButtonId];
网友评论