将图像或视频添加到iPhone模拟器 [英] Adding images or videos to iPhone Simulator

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

问题描述

我正在尝试将UIImagePickerControllerUIImagePickerControllerSourceTypePhotoLibrary一起使用,但显示没有照片".模拟器从何处获取图像?我应该在哪里复制图像,以便在模拟器中显示它们?

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?

推荐答案

将图像,视频等内容下载到模拟器上的最简单方法是将它们从计算机拖放到模拟器上.这将导致模拟器打开照片"应用程序并开始填充图库.

The simplest way to get images, videos, etc onto the simulator is to drag and drop them from your computer onto the simulator. This will cause the Simulator to open the Photos app and start populating the library.

如果您要使用脚本化方法,请继续阅读.

If you want a scriptable method, read on.

注意-虽然这是有效的并且可行,但我认为下面的柯恩解决方案现在是一种更好的解决方案,因为它不需要重启模拟器.

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->设备,选择模拟器并检查标识符值来标识模拟器.

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

,然后添加IMG_nnnn.THM和IMG_nnnn.JPG.然后,您需要重置模拟器(硬件->重新引导),以使其注意到新的更改.它们不是JPEG并不重要-它们都可以是PNG,但是看来它们必须同时存在才能正常工作.如果DCIM不存在,则可能需要创建它,在这种情况下,您应该从nnnn开始于0001.JPG文件是标准版本,而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(-link no longer work).

您还可以通过点击并按住图像,在模拟器中添加来自野生动物园的照片.如果将图像(或任何其他文件,如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天全站免登陆