我在启用接近传感器时,无法使用后置摄像头拍照。我不想显示相机预览,只想让设备拍照并在imageView中展示它。我的接近传感器已经起作用了,并且我正在使用
这是到目前为止我的代码:
imagePicker.takePicture()
在启用 接近传感器时拍照,但似乎不起作用。请问有什么方法/函数可以在没有用户输入的情况下编程地拍照呢?这是到目前为止我的代码:
class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
@IBOutlet var imageView: UIImageView!
var imagePicker: UIImagePickerController!
//*The function in question*
func proximityChanged(notification: NSNotification) {
let device = notification.object as? UIDevice
if device?.proximityState == true {
print("\(device) detected!")