新 Xcode 版本模拟器上的 TouchBar 按钮是什么?
What is this TouchBar button on the simulator on the new Xcode version?
当 运行 来自 Xcode 10.2 的模拟器时,这个新的 Touchbbar 按钮是什么?命令像一个?
模拟器Touch Bar上的⌘>相当于“硬件”»“键盘”»“发送快捷键到设备”。
例如,假设您的应用检测到 command+S 通过 keyCommands
:
class ViewController: UIViewController {
override var keyCommands: [UIKeyCommand]? {
return [UIKeyCommand(input: "s", modifierFlags: .command, action: #selector(didPressCommandS(_:)))]
}
@objc func didPressCommandS(_ keyCommand: UIKeyCommand) {
print(#function, keyCommand)
}
}
不过,通常情况下,如果您在模拟器中按 command+S,它会截取屏幕快照。但是,如果您打开此“将键盘快捷方式发送到设备”(无论是通过触控栏还是通过模拟器的菜单),它将调用您的 UIKeyCommand
选择器,就像在物理设备上一样。
当 运行 来自 Xcode 10.2 的模拟器时,这个新的 Touchbbar 按钮是什么?命令像一个?
模拟器Touch Bar上的⌘>相当于“硬件”»“键盘”»“发送快捷键到设备”。
例如,假设您的应用检测到 command+S 通过 keyCommands
:
class ViewController: UIViewController {
override var keyCommands: [UIKeyCommand]? {
return [UIKeyCommand(input: "s", modifierFlags: .command, action: #selector(didPressCommandS(_:)))]
}
@objc func didPressCommandS(_ keyCommand: UIKeyCommand) {
print(#function, keyCommand)
}
}
不过,通常情况下,如果您在模拟器中按 command+S,它会截取屏幕快照。但是,如果您打开此“将键盘快捷方式发送到设备”(无论是通过触控栏还是通过模拟器的菜单),它将调用您的 UIKeyCommand
选择器,就像在物理设备上一样。