//插入表情
-(void)AppendEmoji:(NSString *)emoji
{
NSRange selectedRange = txtMessage.selectedRange;
if ( selectedRange.location > 0 && selectedRange.location > [[txtMessage text] length] ) {
selectedRange.location = [[txtMessage text] length];
}
NSMutableString* inputext = [[NSMutableString alloc ]initWithString:[txtMessage text]];
[inputext insertString:emoji atIndex:selectedRange.location];
txtMessage.text = inputext;
[inputext release];
// txtMessage.text = [[txtMessage text] stringByAppendingString:[[faceButton titleLabel] text]];
selectedRange.location += emoji.length;//1; 现在emo表情占两个字符
selectedRange.length = 0;
txtMessage.selectedRange = selectedRange;
[txtMessage resignFirstResponder];
}
-(void)AppendEmoji:(NSString *)emoji
{
NSRange selectedRange = txtMessage.selectedRange;
if ( selectedRange.location > 0 && selectedRange.location > [[txtMessage text] length] ) {
selectedRange.location = [[txtMessage text] length];
}
NSMutableString* inputext = [[NSMutableString alloc ]initWithString:[txtMessage text]];
[inputext insertString:emoji atIndex:selectedRange.location];
txtMessage.text = inputext;
[inputext release];
// txtMessage.text = [[txtMessage text] stringByAppendingString:[[faceButton titleLabel] text]];
selectedRange.location += emoji.length;//1; 现在emo表情占两个字符
selectedRange.length = 0;
txtMessage.selectedRange = selectedRange;
[txtMessage resignFirstResponder];
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货