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


当前回答

为此我编写了一个bash脚本。 检查链接[1]

#!/bin/bash

# Imports pictures into all iOS simulators.

path_to_pic="src/ios/pictures/"

mkdir -p /Users/$(whoami)/Library/Application\ Support/iPhone\ Simulator/{5.0,5.1,6.0,6.1}/Media/DCIM/100APPLE/
find ~/Library/Application\ Support/iPhone\ Simulator/ -type d -name '100APPLE' -exec cp /Users/$(whoami)/$path_to_pic/* {} \;

[1] : https://gist.github.com/firesofmay/5194901

其他回答

没有一个答案是我需要的。

我发现自己在iOS 5.0及以上模拟器上工作的步骤如下:

关闭模拟器,如果它正在运行xcode项目。 运行模拟器从码头点击它。 拖放图像到模拟器。 点击并按住图片(在safari中打开)并选择保存选项。

你完成了。

只需拖放图像到iphone模拟器。浏览器将打开显示您的图像。 按下图像,直到你没有收到保存图像的选项。然后保存图像。 就是这样:)。你会看到你的图像在你的模拟器....的照片应用程序

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

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