将粘贴文本复制到 iOS 模拟器中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15188852/
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
Copy paste text into iOS simulator
提问by zerowords
This must be documented somewhere, but I can't find it.
这必须在某处记录,但我找不到它。
In my app using the iPad simulator there is a textfield into which I want the user to paste text. In the real world the user will copy the text from Safari address into the textfield. But I am trying to do that in the ios ipad simulator, but with only partial results.
在我使用 iPad 模拟器的应用程序中有一个文本字段,我希望用户将文本粘贴到其中。在现实世界中,用户会将 Safari 地址中的文本复制到文本字段中。但我试图在 ios ipad 模拟器中做到这一点,但只有部分结果。
After I reRUN the app, I can immediately paste text into the textfield with the Mac's Edit|Paste Text
menu or with Shift-Command-V, (but not with just Edit|Paste
, but that's Ok). The need for the Shift is annoying but I can live with it.
重新运行应用程序后,我可以立即使用 Mac 的Edit|Paste Text
菜单或 Shift-Command-V将文本粘贴到文本字段中(但不能只使用Edit|Paste
,但没关系)。对 Shift 的需求很烦人,但我可以忍受。
But then if I try to copy another URL on the Mac and then again, Edit|Paste Text
or even use the Paste
bubble on the simulator, I don't get the new text, but the original text.
但是,如果我尝试在 Mac 上复制另一个 URL,然后再次复制,Edit|Paste Text
或者甚至Paste
在模拟器上使用气泡,我得到的不是新文本,而是原始文本。
Is that common? Is that a feature of the simulator that it is not connected live to the clipboard on the host computer?
这很常见吗?模拟器的一个特性是它没有实时连接到主机上的剪贴板吗?
采纳答案by Bill Patterson
Be careful to avoid conflating the mac's clipboard with the simulator's clipboard. They are not the same.
小心避免将 mac 的剪贴板与模拟器的剪贴板混淆。她们不一样。
The simulator is simulating an iOS device, with it's own iOS clipboard which apps running on that device (simulator) use via the iOS pup-up select-all/copy/paste UI items.
模拟器正在模拟 iOS 设备,它有自己的 iOS 剪贴板,在该设备(模拟器)上运行的应用程序通过 iOS pup-up select-all/copy/paste UI 项目使用。
Completely separate from that: your mac has it's own clipboard and content. The Simulator program running on your mac provides the Edit > Paste Text menu item. The program implements that menu item by accessing your macclipboard and types the text into the simulatoras if the user used the keyboard. The iOS clipboard is neither accessed nor affected by the Simulator application's Edit menu functions.
与此完全不同:您的 Mac 拥有自己的剪贴板和内容。在 Mac 上运行的模拟器程序提供了 Edit > Paste Text 菜单项。该程序通过访问您的mac剪贴板来实现该菜单项,并将文本输入到模拟器中,就像用户使用键盘一样。iOS 剪贴板既不访问也不受模拟器应用程序的编辑菜单功能影响。
Update:As of Xcode 6, you need to choose the Edit > Paste
menu item in the iOS Simulator (this transfers the data between the Mac clipboard and the iOS Clipboard), then tap in the field in the simulator and tap the "Paste" bubble.
更新:从 Xcode 6 开始,您需要选择Edit > Paste
iOS 模拟器中的菜单项(这会在 Mac 剪贴板和 iOS 剪贴板之间传输数据),然后点击模拟器中的字段并点击“粘贴”气泡。
In your question you don't specify which "Safari" you're copying the URL from. It could be the macsafari application or the simulator'ssafari app. Doing a copy from the mac safari program goes to the mac clipboard, doing a copy from the safari app goes to the iOS clipboard inside the simulator.
在您的问题中,您没有指定要从中复制 URL 的“Safari”。它可能是macsafari 应用程序或模拟器的safari 应用程序。从 mac safari 程序复制到 mac 剪贴板,从 safari 应用复制到模拟器内的 iOS 剪贴板。
I think your issues are coming from confusing the two, thinking there's one clipboard everything is sharing.
我认为您的问题来自混淆了两者,认为所有内容都共享一个剪贴板。
回答by hardanger
I found that even with Edit > Automatically sync pasteboardticked, the feature didn't work.
我发现即使勾选了“编辑”>“自动同步粘贴板”,该功能也不起作用。
However, simply unticking and then reticking this option fixed the feature!
但是,只需取消勾选然后重新勾选此选项即可修复该功能!
Hope it works for someone.
希望它对某人有用。
回答by Shane
Copy text on the mac, then click the text field in the simulator and press
在mac上复制文本,然后点击模拟器中的文本字段并按
Shift Command V
Shift 命令 V
回答by Chathurka
回答by Rajashekar
What worked for me is this.
对我有用的是这个。
1) copy text from Mac
1) 从 Mac 复制文本
2) In simulator do edit->paste or Command V (I think this copies the text from mac clipboard to iOS Simulator clipboard).
2)在模拟器中进行编辑->粘贴或命令V(我认为这会将文本从mac剪贴板复制到iOS模拟器剪贴板)。
3) Highlight the textfield in simulator and then do command + Shift + V.
3)在模拟器中突出显示文本字段,然后执行 command + Shift + V。
回答by Kirill Kudaev
Xcode 10.0+:
Xcode 10.0+:
Turning the Automatic Pasteboard Sync off and then back on again solved the issue.
关闭自动粘贴板同步然后再次打开解决了这个问题。
You might have to do that multiple times.Sometimes it takes a while to trigger it for some reason.
您可能必须多次这样做。有时由于某种原因需要一段时间才能触发它。
(Edit -> Automatic Pasteboard Sync)
(编辑 -> 自动粘贴板同步)
回答by Daniel Lizik
I updated to os x 10.13.6 and xcode 10.1 and there is an added menu in edit
我更新到 os x 10.13.6 和 xcode 10.1 并且有一个添加的菜单 edit
click get pasteboard
then you will be able to paste via the paste tooltip in simulator
单击get pasteboard
然后您将能够通过模拟器中的粘贴工具提示进行粘贴
回答by Mansur76
Similar thing happened to me and I found a strange workaround, it may help anyone else that may come across the same issue. Try the following steps:
类似的事情发生在我身上,我找到了一个奇怪的解决方法,它可能会帮助其他可能遇到相同问题的人。尝试以下步骤:
- Disable and then re-enable the
Automatically Sync Pasteboard
option, it's found under theEdit
menu on the Simulator - Copy the text you want from your Mac
- Paste the text again on your Mac on a text editor like Atom or even your browsers Address Bar
- Select all the text
Cmd+A
and then cut/copyCmd+X
/Cmd+C
- You should now be able to paste the text on the simulator
- 禁用然后重新启用该
Automatically Sync Pasteboard
选项,它Edit
位于模拟器的菜单下 - 从 Mac 复制您想要的文本
- 在 Mac 上的文本编辑器(如 Atom 甚至浏览器地址栏)上再次粘贴文本
- 选择所有文本
Cmd+A
,然后剪切/复制Cmd+X
/Cmd+C
- 您现在应该能够将文本粘贴到模拟器上
回答by Adil Malik
Sometimes it's very difficult to type long URLs in iOS simulator. There should be some way to copy URL from Max OS to iOS text field. Here's how you can do it:
有时在 iOS 模拟器中输入长 URL 非常困难。应该有一些方法可以将 URL 从 Max OS 复制到 iOS 文本字段。您可以这样做:
- Copy some text from Mac
- Open the simulator and click on a text field where you want to paste the text
- Now in Simulator menu click on
Edit
->Paste Text
- 从 Mac 复制一些文本
- 打开模拟器并单击要粘贴文本的文本字段
- 现在在模拟器菜单中点击
Edit
->Paste Text
and that's it. Your text from the Mac OS copy buffer should now be there in iOS simulator's text field.
就是这样。您来自 Mac OS 复制缓冲区的文本现在应该位于 iOS 模拟器的文本字段中。
回答by Eliram
In a new emulator, I got no "paste" option and sync did not work for the simulator. It appears that in the simulator you MUST copy something to the internal clipboard before the sync actually works.
在新的模拟器中,我没有“粘贴”选项,并且同步不适用于模拟器。似乎在模拟器中,您必须在同步实际工作之前将某些内容复制到内部剪贴板。