从 Mac OS X 复制不会复制到 iPhone 模拟器
在我的 iPhone 应用程序中,我有许多 ASCII 艺术,需要将它们插入到数据库中。
我正在使用模拟器并将文本图片粘贴到文本视图中,以将 ASCII 艺术插入数据库。
这里模拟器的剪贴板曾经正确粘贴了艺术作品,但是当我复制另一幅艺术作品时,它也会将以前的艺术作品粘贴到文本视图中。
如何解决这个问题呢?有解决这个问题的方法或者更好的方法吗?
In my iPhone app, I have many ASCII arts which I need to insert into the database.
I am using the simulator and pasting the textpic in the textview to insert the ASCII art to database.
Here the clipboard of simulator once pastes the art properly but when I copy another art then too it pastes the previous art into textview.
How to solve this problem? Is there a work around for this or any better approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
最后一步尝试重新启动 Xcode 和 iOS 模拟器
菜单 ->硬件->重新启动
As a last step try to restart Xcode and iOS simulator
Menu -> Hardware -> Restart
得到了解决方案:
从 iPhone 模拟器菜单。
第三个选项:恢复内容和设置。
您将丢失模拟器中安装的所有应用程序以及设置。
让这个对我有用。
Got the solution:
From iPhone Simulator menu.
Third option: Restore Content and Settings.
You will lose all the apps installed in the simulator along with the settings.
Got this working for me.
我对模拟器中的复制和粘贴感到沮丧,无法弄清楚发生了什么。
结果与您所描述的类似:复制和粘贴有时会粘贴与我之前复制的相同的值,但不是我刚刚复制到剪贴板的值。
我终于意识到模拟器有自己的剪贴板,与主 OS X 剪贴板分开。
您可以使用基于触摸的复制和粘贴命令从模拟器剪贴板粘贴到您的应用程序中。
您可以使用标准 OS X 复制粘贴快捷方式(Command-X、C、V)从系统剪贴板粘贴到模拟器剪贴板。
因此,要从 Chrome(例如)复制和粘贴,您需要在 Chrome 中选择文本,按 Command-C 进行复制。然后切换到模拟器,Command-V粘贴到模拟器剪贴板中。然后在您的应用程序中,您模拟触摸文本字段以调出粘贴选项,然后模拟触摸粘贴按钮以将模拟器剪贴板内容粘贴到应用程序中。
菜单选项的作用与键盘快捷键相同——在系统剪贴板和模拟器键盘之间复制/粘贴。
现在我明白了,实际上我比模拟器剪贴板自动绑定到 OS X 剪贴板更喜欢它。
I was getting frustrated with copy and paste in the simulator and couldn't figure out what was going on.
Results were similar to what you describe: copy and paste would sometimes paste the same value as I had copied before, but not what I just copied to the clipboard.
I finally realized that the simulator has it's own clipboard, separate from the main OS X clipboard.
You use the touch-based copy and paste commands to paste into your application from the simulator clipboard.
You can use the standard OS X copy paste shortcuts (Command-X,C,V) to paste from the system clipboard into the simulator clipboard.
So to copy and paste from Chrome (for example), you select the text in Chrome, Command-C to copy. Then switch to the simulator, Command-V to paste into the simulator clipboard. Then in your application, you simulate a touch in the textfield to bring up the paste option, then simulate a touch to the paste button to paste the simulator clipboard contents into the app.
The menu options do the same thing as the keyboard shortcuts--copy/paste between the system clipboard and the simulator keyboard.
Now that I figured it out, I actually like it much better than if the simulator clipboard was automatically tied to the OS X clipboard.
从 Xcode 9.0 或更高版本:
打开模拟器
从顶部菜单中单击“编辑”
启用 -> “自动同步粘贴板”
如果已启用,则禁用它并再次启用。
长按粘贴您复制的文本
低于Xcode 9.0
它适用于我
From Xcode 9.0 or above:
Open simulator
Click on "Edit" from top menus
Enable -> "Automatically Sync Pasteboard"
If already enable then disable it and enable again.
Long press to paste your text i.e copied
Below Xcode 9.0
it works for me
来源:http://olemoritz.net/copypaste-in-the-ios-simulator.html
Source: http://olemoritz.net/copypaste-in-the-ios-simulator.html
在 Xcode 9 或更高版本中:
1.主动模拟器
2.勾选菜单“编辑->自动同步粘贴板”
3.享受吧:)
In Xcode 9 or above:
1. Active simulator
2. Check menu "Edit -> Automatically Sync Pasteboard"
3. Enjoy :)
我为此寻找答案有一段时间了。对于 Apple Silicon (M1),我最终找到了一个页面,一些用户在其中追踪到了它iOS 14+ 的问题。当我按照说明安装切换到模拟器 iOS 13.7 时(请参阅链接),粘贴再次起作用。虽然这显然不是最初问题(10 年前!)的情况,但我将其粘贴到此处以防其他人遇到此问题。
I searched for an answer for this for some time. For Apple Silicon (M1) I eventually found a page where some users had tracked it down to an issue with iOS 14+. When I installed switched to a simulator iOS 13.7 as instructed (see link) pasting worked again. While this is clearly not what was going on with the original question (10 years ago!), I am pasting here in case someone else has this issue.
这是我电脑上的奇怪问题。我的 Mac 上安装了 macOs Sierra 10.xx++。我所做的是,
使用
command + c
或键盘从您的Mac复制内容。现在在您要粘贴内容的特定位置按
command + v
。现在使用
command + shift + v
粘贴到模拟器中运行良好。确认答案。!
This is strange issue in my pc. I have macOs Sierra 10.xx++ installed in my mac. What i do is ,
Copy the content from your mac using
command + c
or keyboard.Now press
command + v
in the particular place you want to paste the content.Now Paste in the simulator using
command + shift + v
Working well. Confirmed answer.!
查看
UITextView
的text
属性。只需将您的文本图片加载到NSString
中,然后将该字符串设置为 TextView 的text
属性即可。http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html%23//apple_ref/occ/instp/UITextView/text
Check out the
text
property of theUITextView
. Simply load your textpic into anNSString
, and set that string to be thetext
property of the TextView.http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html%23//apple_ref/occ/instp/UITextView/text
您可以使用 ⌘ + ⇧ + C 从 Mac 复制内容,并使用 ⌘ + V 粘贴到浏览器 URL 中。
它对我有用。
You can copy the content from mac using ⌘ + ⇧ + C and paste in browser url using ⌘ + V .
It's working for me.