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


当前回答

对于iOS 4.2,我必须创建100APPLE文件夹并重新启动模拟器,然后它就工作了。

其他回答

对于iOS 8.0,答案已经过时了。我在以下路径找到了媒体资源: ~ /图书馆/开发/ CoreSimulator /设备/[的DeviceID] /数据/媒体/ DCIM / 100苹果

在iOS 11和Xcode 9中,只需将照片拖放到模拟器中即可。它会自动在图书馆应用程序中导入它们。非常简单!

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.重新启动模拟器以查看新文件。

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 5.1,这将进一步更改为new path

~/库/应用程序支持/iPhone模拟器/5.1/媒体/DCIM/100APPLE