我试图使用UIImagePickerController与UIImagePickerControllerSourceTypePhotoLibrary,但它说,“没有照片”。模拟器从哪里获得图像?我应该在哪里复制图像,以便它们在模拟器中显示?
当前回答
使用拖放功能,您将丢失照片的所有元数据。
我已经创建了一个项目,可以很容易地将资产导入模拟器:MBAssetsImporter。
它使您可以导入视频和照片,同时保留文件的所有原始元数据。
其他回答
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
确保设备处于运行状态。 在终端执行以下命令:
open ~/Library/Developer/CoreSimulator/Devices/$(xcrun simctl list | grep Booted | grep - eo '[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*')/data/Media/DCIM
进一步的regex ref @ https://regex101.com/r/tY951n/3
如果你需要导入不止一、两张照片,那就看看我写的这篇文章。它描述了一种简单的方法来执行批量导入照片,适用于iOS 4.x。
对于iOS 7,我做了以下操作:
复制照片到这两个文件夹:
~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
~/Library/Application Support/iPhone Simulator/7.0/Media/DCIM/100APPLE
只删除这4个文件(以避免重新启动时重复):
~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-wal
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-wal
推荐文章
- 如何删除默认的导航栏空间在SwiftUI导航视图
- Ios模拟器:如何关闭应用程序
- 如何在iOS中使用Swift编程segue
- Swift -整数转换为小时/分钟/秒
- Swift:声明一个空字典
- 在成功提交我的应用程序后,“太多符号文件”
- 首先添加一个UIView,甚至是导航栏
- 我如何改变UIButton标题颜色?
- 在Swift中如何调用GCD主线程上的参数方法?
- NSLayoutConstraints是可动画的吗?
- iOS -构建失败,CocoaPods无法找到头文件
- Xcode 4挂在“附加到(应用程序名称)”
- CFNetwork SSLHandshake iOS 9失败
- 请求失败:不可接受的内容类型:文本/html使用AFNetworking 2.0
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式