xcode 如何在 iphone 模拟器上使用键盘输入?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3954405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I type using my keyboard on the iphone simulator?
提问by strange
I used to be able to type with my real mac keyboard after launching the iPhone Simulator. Typing with the on-screen simulator keyboard is just horrible when testing with large amounts of text.
在启动 iPhone 模拟器后,我曾经能够用我的真实 mac 键盘打字。在测试大量文本时,使用屏幕模拟器键盘打字非常糟糕。
No matter what I do, I can't get my keyboard to type anymore inside the simulator. Even if I have "Simulate Hardware Keyboard" switched ON, it just won't type anything. Can someone please tell me what I'm doing wrong? Is there no way to type using the real keyboard anymore?
无论我做什么,我都无法让我的键盘在模拟器中输入。即使我打开了“模拟硬件键盘”,它也不会输入任何内容。有人可以告诉我我做错了什么吗?再也没有办法使用真正的键盘打字了吗?
回答by David Brown
Try trashing the iPhone Simulator preferences file. When my iPhone Simulator stopped responding to keystrokes, this fixed it.
尝试删除 iPhone 模拟器首选项文件。当我的 iPhone 模拟器停止响应按键时,这修复了它。
- Quit the simulator.
- Go to finder and press (command+shift+G) then navigate
~/Library/Preferences
. - Move
com.apple.iphonesimulator.plist
to the trash. - Try launching your iPhone app in the simulator again.
- 退出模拟器。
- 转到 finder 并按 (command+shift+G) 然后导航
~/Library/Preferences
。 - 移动
com.apple.iphonesimulator.plist
到回收站。 - 再次尝试在模拟器中启动您的 iPhone 应用程序。
回答by slamor
Deleting com.apple.iphonesimulator.plist did not help me under Xcode 6.0.1. Probably, it worked in old Xcode.
删除 com.apple.iphonesimulator.plist 在 Xcode 6.0.1 下对我没有帮助。可能,它适用于旧的 Xcode。
But, what works perfectly for me under Xcode 6.0.1, it is new hot Keys in iOS Simulator:
但是,在 Xcode 6.0.1 下对我来说完美的是什么,它是 iOS 模拟器中的新热键:
Shift-Command-K Connect/Disconnect Hardware Keyboard
Command-K Toggle (Show/Hide) Software Keyboard
And, you know, I really suffered for last 2 months, until found it, and it is very convenient now))
而且,你知道,我真的受苦了 2 个月,直到找到它,现在很方便))
回答by Benjohn
Don't trash the iPhone simulator preference files.There's no need to do this.
不要丢弃 iPhone 模拟器首选项文件。没有必要这样做。
Look in the simulator's menu Hardware ? Keyboard
. The menu options are:
查看模拟器的菜单Hardware ? Keyboard
。菜单选项是:
- iOS Uses Same Layout as OS X
- Connect Hardware Keyboard ??K
- Toggle Software Keyboard ?K
- iOS 使用与 OS X 相同的布局
- 连接硬件键盘??K
- 切换软件键盘 ?K
Ensure option 2 is checked.
确保选中选项 2。
If it's already checked, uncheck it then check it again (you'll probably want to learn the keyboard shortcuts).
如果它已经被选中,取消选中它然后再次选中它(你可能想学习键盘快捷键)。
If you find that this hides the on screen keyboard, but you also want this to show, use option 3 to toggle it back on.
如果您发现这隐藏了屏幕键盘,但您也希望显示它,请使用选项 3 将其重新打开。
If rotating the simulator seems to stop the keyboard working, toggle option two off then back on – this seems to resolve it.
如果旋转模拟器似乎停止了键盘工作,请关闭选项二然后重新打开 - 这似乎可以解决它。
回答by nocturnalbee
I am using iOS Simulator Version 7.0. While the simulator was running I went to iOS Simulator->Reset Contents and Settings... and reset the simulator from there. That seemed to have done the trick for me. Hope that helps.
我正在使用 iOS 模拟器 7.0 版。在模拟器运行时,我转到 iOS Simulator->Reset Contents and Settings... 并从那里重置模拟器。这似乎对我有用。希望有帮助。
回答by gunas
This is because you have used changing the orientation of simulator using keyboard shortcuts. Just press cmd on the mac keyboard then start typing.
这是因为您已经使用键盘快捷键更改了模拟器的方向。只需在 Mac 键盘上按 cmd 即可开始输入。
回答by Chicowitz
All I needed to do was quit the simulator and launch it again
我需要做的就是退出模拟器并再次启动它
回答by Ram Madhavan
MY PROBLEM WAS KEYBOARD IS SHOWING AND KEYSTROKES NOT DETECTING. AND I FOUND THE SOLUTION:
我的问题是键盘正在显示并且没有检测到击键。我找到了解决方案:
You don't need to quit the keyboard.
您无需退出键盘。
Try Hardware->Keyboard->Connect Hardware Keyboard directly
尝试硬件->键盘->直接连接硬件键盘
回答by James
Removing com.apple.iphonesimulator.plist
worked for me too, but I had to locate it inside the hidden folder /Users/[yourusername]/Library/Preferences/
删除com.apple.iphonesimulator.plist
也对我有用,但我必须在隐藏文件夹中找到它/Users/[yourusername]/Library/Preferences/
回答by Evgeny Faddeenkov
Shell / Command-Line / Jenkins / CI:
Shell / 命令行 / Jenkins / CI:
sh "plutil -replace DevicePreferences.${deviceID}.ConnectHardwareKeyboard -bool NO $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
sh "plutil -extract DevicePreferences.${deviceID} xml1 -o - $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
The Device ID can be found via xcrun / simctl, based on the devoce name:
设备 ID 可以通过 xcrun / simctl 找到,基于设备名称:
xcrun simctl list | grep ${simulatorDeviceName} | sed 's/).*(.*//;s/.*(//'
回答by Dmitry
Just restart Simulator (close and open the app).
只需重新启动模拟器(关闭并打开应用程序)。