您的位置:首页 > 其它

新浪微博客户端(41)-切换表情键盘

2016-11-26 22:11 197 查看
DJComposeViewController.m

#pragma mark - 切换键盘
- (void)switchKeyboard {

// textView.inputView 代表的就是键盘
if (self.textView.inputView) { // 默认self.textView.inputView = nil, 为nil则代表默认为系统键盘
self.textView.inputView = nil;
} else {
DJEmotionKeyboard *emotionKeyboard = [[DJEmotionKeyboard alloc] init];
emotionKeyboard.width = self.view.width;
emotionKeyboard.height = 216; // IOS 系统键盘高度一般都是216
self.textView.inputView = emotionKeyboard;
}

// 先调用endEditing,再调用becomeFirstResponder才可造成键盘效果
[self.textView endEditing:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.textView becomeFirstResponder];
});

}


最终效果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: