diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..30acc2e --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,8 @@ +{ + "permissions": { + "allow": [ + "WebSearch", + "Bash(git checkout:*)" + ] + } +} diff --git a/CustomKeyboard/KeyboardViewController.m b/CustomKeyboard/KeyboardViewController.m index 9ef1e72..420c07e 100644 --- a/CustomKeyboard/KeyboardViewController.m +++ b/CustomKeyboard/KeyboardViewController.m @@ -197,6 +197,14 @@ static NSString *KBFormatMB(uint64_t bytes) { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + // FIX: iOS 26 键盘闪烁问题 —— 恢复键盘正确高度 + // setupUI 中高度初始为 0(防止系统预渲染快照闪烁),此处恢复为实际键盘高度。 + // 此时系统已准备好键盘滑入动画,恢复高度后键盘将正常从底部滑入。 + CGFloat portraitWidth = [self kb_portraitWidth]; + CGFloat keyboardHeight = [self kb_keyboardHeightForWidth:portraitWidth]; + if (self.kb_heightConstraint) { + self.kb_heightConstraint.constant = keyboardHeight; + } // 进入/重新进入输入界面时,清理上一次会话残留的撤销状态与缓存,避免显示“撤销删除”但实际上已不可撤销。 [[KBBackspaceUndoManager shared] registerNonClearAction]; [[KBInputBufferManager shared] resetWithText:@""]; @@ -263,8 +271,15 @@ static NSString *KBFormatMB(uint64_t bytes) { CGFloat keyboardBaseHeight = [self kb_keyboardBaseHeightForWidth:portraitWidth]; CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds); + // FIX: iOS 26 键盘闪烁问题 + // iOS 26 在键盘滑入动画开始前,会对 self.view 做一次离屏预渲染快照(非实时 view), + // 该快照会短暂显示在屏幕中间。如果此时 view 已有完整高度和内容,用户就会看到 + // 键盘 UI 在屏幕中间闪现一帧,然后键盘才从底部正常滑入。 + // 解决方案:初始高度设为 0,让系统快照时无内容可渲染; + // 在 viewWillAppear: 中恢复正确高度,此时系统已准备好滑入动画。 + // (iOS 18 及更早版本无此预渲染机制,不受影响) NSLayoutConstraint *h = - [self.view.heightAnchor constraintEqualToConstant:keyboardHeight]; + [self.view.heightAnchor constraintEqualToConstant:0]; NSLayoutConstraint *w = [self.view.widthAnchor constraintEqualToConstant:screenWidth]; self.kb_heightConstraint = h;