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


当前回答

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

其他回答

对于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

使用Xcode 6+ (iOS Simulator 8.1及以上版本)附带的新iOS模拟器,这要容易得多。现在你所要做的就是把一张或多张照片拖到iOS模拟器窗口上,然后不是打开Safari浏览器,而是打开照片应用程序,并立即将所有拖进来的照片添加到设备中。

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.

如果你不能拖放你的文件,因为你遇到错误:

一个或多个媒体项导入失败::操作无法完成。(PHPhotosErrorDomain错误-1.)

将文件移动到Documents文件夹中,然后将它们拖到模拟器中。这将触发模拟器请求访问文件的权限。将它们放在下载文件夹中则不会。

1. CD到此路径:

/用户/ (macOS用户)/图书馆/开发/ CoreSimulator /设备/[模拟器 标识符]/数据/媒体/ DCIM / 100苹果 [模拟器标识符]或UDID可以在以下位置找到:Hardware => device => manage devices。 如。cd /用户/ rnDeveloper /图书馆/开发/ CoreSimulator /设备/ 7508171 a-dc5d-47cf-9be1-ff950326e3db /数据/媒体/ DCIM / 100苹果

2. 下载图片:

Curl -o pic_001.jpg “https://s-media-cache-ak0.pinimg.com/474x/49/25/7a/49257a4b3287b7841922ecdff855fd80.jpg”

3.重新启动模拟器以查看新文件。