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]; }); }
最终效果:
时间: 2024-11-02 23:32:33