添加举报
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
@property (nonatomic, assign) CGFloat voiceInputBarHeight;
|
||||
@property (nonatomic, assign) CGFloat baseInputBarBottomSpacing;
|
||||
@property (nonatomic, assign) CGFloat currentKeyboardHeight;
|
||||
/// 仅用于标记“由 KBVoiceInputBar 触发的键盘”是否处于激活态
|
||||
@property (nonatomic, assign) BOOL voiceInputKeyboardActive;
|
||||
@property (nonatomic, strong) UITapGestureRecognizer *dismissKeyboardTap;
|
||||
@property (nonatomic, weak) LSTPopView *chatLimitPopView;
|
||||
|
||||
@@ -76,6 +78,31 @@
|
||||
|
||||
@implementation KBAIHomeVC
|
||||
|
||||
#pragma mark - Keyboard Gate
|
||||
|
||||
/// 查找当前 view 树里的 firstResponder
|
||||
- (UIView *)kb_findFirstResponderInView:(UIView *)view {
|
||||
if ([view isFirstResponder]) {
|
||||
return view;
|
||||
}
|
||||
for (UIView *sub in view.subviews) {
|
||||
UIView *found = [self kb_findFirstResponderInView:sub];
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// 仅允许 KBVoiceInputBar 触发键盘联动(避免评论输入等场景误触发)
|
||||
- (BOOL)kb_isKeyboardFromVoiceInputBar {
|
||||
UIView *firstResponder = [self kb_findFirstResponderInView:self.view];
|
||||
if (!firstResponder) {
|
||||
return NO;
|
||||
}
|
||||
return [firstResponder isDescendantOfView:self.voiceInputBar];
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (void)viewDidLoad {
|
||||
@@ -353,6 +380,21 @@
|
||||
// 将键盘的 frame 转换到当前 view 的坐标系
|
||||
CGRect convertedFrame = [self.view convertRect:endFrame fromView:nil];
|
||||
CGFloat keyboardHeight = MAX(0.0, CGRectGetMaxY(self.view.bounds) - CGRectGetMinY(convertedFrame));
|
||||
|
||||
// Gate:只让 KBVoiceInputBar 触发聊天区域的联动(评论输入等场景会误触发)
|
||||
if (keyboardHeight > 0.0) {
|
||||
if (![self kb_isKeyboardFromVoiceInputBar]) {
|
||||
return;
|
||||
}
|
||||
self.voiceInputKeyboardActive = YES;
|
||||
} else {
|
||||
// 键盘收起时:只有之前是由 KBVoiceInputBar 触发的,才需要恢复
|
||||
if (!self.voiceInputKeyboardActive) {
|
||||
return;
|
||||
}
|
||||
self.voiceInputKeyboardActive = NO;
|
||||
}
|
||||
|
||||
self.currentKeyboardHeight = keyboardHeight;
|
||||
|
||||
NSLog(@"[KBAIHomeVC] 键盘高度: %.2f, 屏幕高度: %.2f, 键盘 Y: %.2f",
|
||||
|
||||
Reference in New Issue
Block a user