将图像添加到iPhone模拟器 [英] Adding images to iPhone Simulator

查看:128
本文介绍了将图像添加到iPhone模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use UIImagePickerController with UIImagePickerControllerSourceTypePhotoLibrary, but it says, "No photos". Where does the simulator get the images from? Where should I copy the images so that they are displayed in the simulator?

推荐答案

注意 - 虽然这是有效的,但是有效,我认为下面的Koen解决方案现在更好了,因为它不需要重启模拟器。

Note - while this is valid, and works, I think Koen's solution below is now a better one, since it does not require rebooting the simulator.

通过转到xCode-> Devices,选择模拟器并检查Identifier值来识别模拟器。

Identify your simulator by going to xCode->Devices, selecting your simulator, and checking the Identifier value.

转到

〜/ Library / Developer / CoreSimulator / Devices / [Simulator Identifier] / data / Media / DCIM / 100APPLE

~/Library/Developer/CoreSimulator/Devices/[Simulator Identifier]/data/Media/DCIM/100APPLE

and添加IMG_nnnn.THM和IMG_nnnn.JPG。然后,您需要重置模拟器(硬件 - >重新启动)以允许它注意新的更改。如果它们不是JPEG也没关系 - 它们都可以是PNG,但似乎它们都必须存在才能工作。您可能需要创建DCIM(如果它尚不存在),在这种情况下,您应该从0001开始nnnn.JPG文件是fullsize版本,而THM文件是缩略图,大小为75x75像素。我写了一个脚本来做这个,但是有一个更好的文件记录了这里

and add IMG_nnnn.THM and IMG_nnnn.JPG. You will then need to reset your simulator (Hardware->Reboot) to allow it to notice the new changes. It doesn't matter if they are not JPEGs - they can both be PNGs, but it appears that both of them must be present for it to work. You may need to create DCIM if it doesn't already exist, and in that case you should start nnnn from 0001. The JPG files are the fullsize version, while the THM files are the thumbnail, and are 75x75 pixels in size. I wrote a script to do this, but there's a better documented one over here.

您还可以通过点击并按住图像,在模拟器中添加safari中的照片。如果将图像(或任何其他文件,如PDF)拖动到模拟器,它将立即打开Safari并显示图像,因此这是获取图像的一种简单方法。

You can also add photos from safari in the simulator, by Tapping and Holding on the image. If you drag an image (or any other file, like a PDF) to the simulator, it will immediately open Safari and display the image, so this is quite an easy way of getting images to it.

这篇关于将图像添加到iPhone模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆