我试图使用UIImagePickerController与UIImagePickerControllerSourceTypePhotoLibrary,但它说,“没有照片”。模拟器从哪里获得图像?我应该在哪里复制图像,以便它们在模拟器中显示?
当前回答
只需将图像拖到iPhone模拟器。
其他回答
将图像、视频等放到模拟器上的最简单方法是将它们从计算机拖放到模拟器上。这将导致模拟器打开照片应用程序并开始填充库。
如果您想要一个可编写脚本的方法,请继续阅读。
注意-虽然这是有效的,并且工作,我认为Koen下面的解决方案现在是一个更好的,因为它不需要重新启动模拟器。
通过到xCode->Devices,选择您的模拟器,并检查Identifier值来识别您的模拟器。或者,您可以确保模拟器正在运行,并运行以下命令获取设备ID xcrun simctl list | grep Booted
去
~ /图书馆/开发/ CoreSimulator /设备/(模拟器标识符)/数据/媒体/ DCIM / 100苹果
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).
你也可以在模拟器中通过点击并按住图片来添加safari中的照片。如果您将图像(或任何其他文件,如PDF)拖到模拟器,它将立即打开Safari并显示图像,因此这是一种非常简单的获取图像的方法。
一步一步解释Airsource有限公司为模拟器添加图像的答案:
拖到模拟器,然后打开Safari (或使用Safari浏览器在互联网上浏览图片) 按住图像上的鼠标 当弹出窗口出现时,选择保存图像并享受;)
更新:对于iOS模拟器4.2,执行这些步骤两次以使其工作。谢谢kevboh !
更新:这也适用于iOS模拟器6.1
3个简单步骤
拖放图像到模拟器 -这将打开一个浏览器与您的图像 点击并按住图片 -这将打开选项 保存图像 -这将复制图像到模拟器
观看YouTube视频(将图像添加到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.
使用Xcode 6+ (iOS Simulator 8.1及以上版本)附带的新iOS模拟器,这要容易得多。现在你所要做的就是把一张或多张照片拖到iOS模拟器窗口上,然后不是打开Safari浏览器,而是打开照片应用程序,并立即将所有拖进来的照片添加到设备中。
推荐文章
- 保留HTML字体大小时,iPhone的方向从纵向改变为横向
- iPhone上UIView和UILabels的渐变
- keychain上的分发证书中缺少私钥
- 在实现API时,我如何避免在块中捕获自我?
- 如何创建一个Swift Date对象?
- Xcode 4在目标设备上说“finished running <my app>”——什么都没有发生
- 从另一个应用程序打开设置应用程序
- 快速提取正则表达式匹配
- 如何应用梯度的背景视图的iOS Swift应用程序
- 图书馆吗?静态的?动态吗?或框架?另一个项目中的项目
- 如何用SwiftUI调整图像大小?
- Xcode 6 gitignore文件应该包括什么?
- 如何在iPhone/iOS上删除电话号码的蓝色样式?
- 检测视网膜显示
- 如何在UIImageView中动画图像的变化?