Skip to content

iOS 14 上输入控件弹出系统键盘后,点击系统键盘的表情切换,会导致崩溃 #1042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0x1306a94 opened this issue Jul 4, 2020 · 3 comments
Labels

Comments

@0x1306a94
Copy link
Contributor

Bug 表现
问题的具体描述
集成QMUIKit的项目,在iOS 14 上输入控件弹出系统键盘后,点击系统键盘的表情切换,会导致崩溃

截图

我的解决方案如下
UITextInputTraits+QMUI.m文件中

ExtendImplementationOfNonVoidMethodWithSingleArgument(inputClass, @selector(initWithFrame:), CGRect, UIView<UITextInputTraits> *, ^UIView<UITextInputTraits> *(UIView<UITextInputTraits> *selfObject, CGRect firstArgv, UIView<UITextInputTraits> *originReturnValue) {
    if (QMUICMIActivated) selfObject.keyboardAppearance = KeyboardAppearance;
    selfObject.qti_didInitialize = YES;
    return originReturnValue;
});

替换为如下代码

ExtendImplementationOfNonVoidMethodWithSingleArgument(inputClass, @selector(initWithFrame:), CGRect, UIView<UITextInputTraits> *, ^UIView<UITextInputTraits> *(UIView<UITextInputTraits> *selfObject, CGRect firstArgv, UIView<UITextInputTraits> *originReturnValue) {
   // iOS 14 上切换系统表情输入法时, 系统会创建 TUIEmojiSearchTextField
   // 此时如果在这里设置 keyboardAppearance 就会导致 一直调用 -[TUIEmojiSearchTextField initWithFrame:pretendsToBecomeFirstResponder:]
   // 最终死循环导致crash
   if (![NSStringFromClass(selfObject.class) isEqualToString:@"TUIEmojiSearchTextField"] && QMUICMIActivated) {
      selfObject.keyboardAppearance = KeyboardAppearance;
   }
   selfObject.qti_didInitialize = YES;
   return originReturnValue;
});

其他信息

  • 设备: [模拟器、iPhone]
  • iOS 版本: [iOS 14]
  • Xcode 版本: [Xcode 11, Xcode 12 beta]
  • QMUI 版本: [4.1.1]
@CloudlessMoon
Copy link

+1

@ziecho
Copy link
Collaborator

ziecho commented Jul 14, 2020

感谢反馈,我们下个版本处理一下,可以按照提供的解决方法修改源码。

@MoLice MoLice added the bug label Jul 29, 2020
@MoLice
Copy link
Collaborator

MoLice commented Jul 29, 2020

已发布 4.2.0 修复该问题。

@MoLice MoLice closed this as completed Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants