在iPhone应用程序中检测相机的存在? [英] Detect existence of camera in iPhone app?

查看:121
本文介绍了在iPhone应用程序中检测相机的存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写iOS应用程序,我需要能够检测设备是否有摄像头。以前,我会检查设备是否是iPhone,因为只有iPhone有摄像头 - 但随着iPod Touch 4的推出,这已不再是一个可行的选择。该应用程序在没有相机的情况下运行,但相机的存在增加了功能。

I'm writing an iOS app, and I need to be able to detect if the device has a camera. Previously, I would check if the device is an iPhone or not, since only the iPhone has a camera - but with the launch of the iPod Touch 4 this is no longer a viable option. The app functions without a camera, but the presence of a camera adds functionality.

那么,任何人都可以向我提供返回是否有相机的代码吗? / p>

So, can anyone provide me with code that returns whether there is a camera or not?

推荐答案

你可以在UIImagePickerController中使用 + isSourceTypeAvailable:方法:

You can use +isSourceTypeAvailable: method in UIImagePickerController:

if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
   // Has camera

这篇关于在iPhone应用程序中检测相机的存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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