Ios 在Macbook上找不到摄像头
我已经按照教程创建了一个可以预览相机的应用程序,第一步是列出可以使用的媒体设备 但我得到了一份零发明的清单,而我的macbook相机却无处可寻Ios 在Macbook上找不到摄像头,ios,xcode,Ios,Xcode,我已经按照教程创建了一个可以预览相机的应用程序,第一步是列出可以使用的媒体设备 但我得到了一份零发明的清单,而我的macbook相机却无处可寻 import UIKit import AVFoundation class ViewController: UIViewController { let captureSession = AVCaptureSession() var previewLayer : AVCaptureVideoPreviewLayer? var
import UIKit
import AVFoundation
class ViewController: UIViewController {
let captureSession = AVCaptureSession()
var previewLayer : AVCaptureVideoPreviewLayer?
var captureDevice : AVCaptureDevice?
override func viewDidLoad() {
super.viewDidLoad()
captureSession.sessionPreset = AVCaptureSessionPresetHigh
let devices = AVCaptureDevice.devices()
println("FOOBAR")
println(devices.count)
for device in devices {
println("HELLO")
if (device.hasMediaType(AVMediaTypeVideo)) {
if(device.position == AVCaptureDevicePosition.Back) {
captureDevice = device as? AVCaptureDevice
if captureDevice != nil {
println("Capture device found")
beginSession()
}
}
}
}
}
func beginSession() {
}
}
我将删除对device.position==AVCaptureDevicePosition.Back的检查。在我的经验中,Debug。位置似乎总是在Mac OS X.< /P>上返回NIL,通常相机正好位于显示器面向用户的边框的中间。抱歉,无法抗拒,因为您在标题中的表述:-