xcode iOS模拟器中是否有相机设备模拟?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50523686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:39:23  来源:igfitidea点击:

Is there Camera Device Simulation in iOS Simulators?

iosxcodeios-simulator

提问by user155

Android emulators can simulate Camera device (see screenshot) For example I can test how my video recording module works:

Android 模拟器可以模拟相机设备(见截图)例如我可以测试我的视频录制模块是如何工作的:

Android Emulator, camera simulation example

Android Emulator,相机模拟示例

What about iOS-Simulators? When I try to run my app which uses camera I get the next error

iOS模拟器呢?当我尝试运行使用相机的应用程序时,出现下一个错误

Thread 5: Fatal error: Unexpectedly found nil while unwrapping an Optional value

at line

在线

let videoDeviceInput = try AVCaptureDeviceInput(device: defaultVideoDevice!)

so no simulated devices are available for iOS-Simulators?

所以没有可用于 iOS 模拟器的模拟设备?

回答by Hassan Shahbazi

According to Apple documentation, using camera with Simulator is not supported:

根据Apple 文档,不支持在模拟器中使用相机:

The following hardware is not supported in Simulator:

  • Ambient light sensor

  • Audio input, except for using Siri by choosing Hardware > Siri.

  • Barometer

  • Bluetooth

  • Camera

  • Motion support (accelerometer and gyroscope)

  • Proximity sensor

Simulator 不支持以下硬件:

  • 环境光传感器

  • 音频输入,除了通过选择硬件 > Siri 使用 Siri。

  • 晴雨表

  • 蓝牙

  • 相机

  • 运动支持(加速度计和陀螺仪)

  • 接近传感器