gpt4 book ai didi

ios - 检测 iOS 键盘上的 Shift + Enter

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:29 25 4
gpt4 key购买 nike

是否可以在 iOS 上的 UITextView 中检测到 Shift + Enter 组合键?

最佳答案

使用 Swift,您可以在 UIResponder 子类中拦截 Shift + Enter 的组合,方法如下:

override var keyCommands: [UIKeyCommand]? {
get {
return [UIKeyCommand(input: "\r", modifierFlags: .shift , action: #selector(handleShiftEnter(command:)))]
}
}

func handleShiftEnter(command: UIKeyCommand) {
print("Combo pressed! Default action intercepted!")
}

关于ios - 检测 iOS 键盘上的 Shift + Enter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27933898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com