我试图使用UIImagePickerController与UIImagePickerControllerSourceTypePhotoLibrary,但它说,“没有照片”。模拟器从哪里获得图像?我应该在哪里复制图像,以便它们在模拟器中显示?


当前回答

试试我做的这个应用。下载代码并在模拟器https://github.com/cristianbica/CBSimulatorSeed中运行

其他回答

确保设备处于运行状态。 在终端执行以下命令:

open ~/Library/Developer/CoreSimulator/Devices/$(xcrun simctl list | grep Booted | grep - eo '[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*')/data/Media/DCIM

进一步的regex ref @ https://regex101.com/r/tY951n/3

从iOS 8开始,你只需将所有照片拖到模拟器窗口,它们就会自动保存到相机胶卷上。你可以想做多少就做多少。

方法1(最简单的方法):如果你的图像在Mac上

您可以将图像从Mac上的Finder拖到模拟器,它就会保存到“已保存的照片”相册中。

方法2:如果它在任何URL

将图片从网页保存到“照片”应用程序

将指针放在要保存的图像上,并按住鼠标按钮或触摸板。 当菜单出现时,单击Save Image将图像保存到iOS模拟器中的Photos应用程序中。 图片被保存到“照片”应用程序的“已保存照片”相册中。

以防有人在模拟器中寻找关于复制和粘贴的苹果文档。

我只是需要一些随机的图像进行测试,所以这就是我所做的。

我有世界上最简单的解决办法。只需在模拟器中打开Safari,转到谷歌图像(或您自己的web或Dropbox URL),查看图像,按住鼠标按钮2秒,你会看到“保存图像”-它会保存到照片库中。清洗并重复。

quit the simulator.

Run simulator from the dock by clicking on it.

Drag & drop the image into simulator which you want to add.

it will open image in safari .

tap and hold the image and click the save option.

then open gallery and you will see the image which u had saved recently.