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


当前回答

对于iOS 7,我做了以下操作:

复制照片到这两个文件夹:

~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
~/Library/Application Support/iPhone Simulator/7.0/Media/DCIM/100APPLE

只删除这4个文件(以避免重新启动时重复):

~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-wal
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-wal

其他回答

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.

使用您的电脑只需通过电子邮件发送图像 打开ios模拟器,然后打开电子邮件并下载图像 只需单击并按住图像上的鼠标,从选项中就会显示出来 然后,它会自动保存到你的ios模拟器的图片库

如果你需要导入不止一、两张照片,那就看看我写的这篇文章。它描述了一种简单的方法来执行批量导入照片,适用于iOS 4.x。

最简单的解决方案是在模拟器上登录iCloud,然后使用iCloud传输驱动器中的任何文件,包括照片。

对于iOS 8,如果不需要保留照片捕捉日期和位置,只需将照片文件放到模拟器中即可。

要保留照片元数据,请执行以下操作:

复制照片文件到:/Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/DCIM/100Apple 删除(或重命名)文件夹:/Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/photoData 重新启动模拟器

注意:您需要用您的用户名替换{USER},用模拟器的UDID替换{UDID}。要从终端找到模拟器的UDID,请运行“xcrun simctl list”。