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


当前回答

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

其他回答

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.

使用拖放功能,您将丢失照片的所有元数据。

我已经创建了一个项目,可以很容易地将资产导入模拟器:MBAssetsImporter。

它使您可以导入视频和照片,同时保留文件的所有原始元数据。

它的简单。只需遵循以下步骤:

拖放图像到模拟器 现在图像打开到Safari浏览器(文件://…/ImageName)。点击并按住图像。 这将显示带有保存,取消选项的actionSheet(在iOS 7模拟器的情况下也复制)。 保存图像。图像被添加到Library中。

只是告诉你:KONG的解决方案也适用于iOS 7测试版。

他的解决方案是:

将图像拖到模拟器,然后打开Safari(或在互联网上使用Safari浏览图像) 按住图像上的鼠标 当弹出窗口出现时,选择保存图像并享受;)

从Xcode 6开始,你可以使用命令行工具xcrun simctl。

用法非常简单;要将照片添加到当前运行的模拟器中,您可以使用引导占位符。

xcrun simctl addmedia booted ./MyFile.jpg

要将它添加到任何其他模拟器,您可以使用它的设备id,可以通过运行xcrun simctl list找到它。

xcrun simctl addmedia E201E636-CE6C-11E5-AB30-625662870761 ./MyFile.jpg