背景
iOS16之后根据UIApplication.shared.windows.last获取UIRemoteKeyboardWindow方式失效,导致表情包长按预览图到了InputView之下,打印其并不在UIApplication.shared.windows之中
临时获取UIRemoteKeyboardWindow解决方案
//注:emojiBoardView为TextField的inputView
if let keyBoardWindow = vc.emojiBoardView.superview?.superview?.superview as? UIWindow {
keyBoardWindow.windowLevel = keyBoardWindow.windowLevel + 1
keyBoardWindow.addSubview(self)
self.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
有没有更好的方法?
网友评论