나는이 코드를 가지고 있으며 노란색 경고를 던지고있다. 노란색 경고가 사라지도록 코드를 작성하는 방법을 알아낼 수 없습니다. > 3 - - 스위프트-2에서 변환 한 후 내 코드를 정리하려고> 4.'[AVCaptureDevice]'에서 '[AVCaptureDevice]'까지 조건부 캐스트가 항상 성공합니다. 노란색 경고
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//On iPad Mini this returns 760 x 1024 = correct
//On the iPhone SE, this returns 320x568 = correct
print("Width: \(screenWidth)")
print("Height: \(screenHeight)")
//=======================
captureSession.sessionPreset = AVCaptureSession.Preset.high
if #available(iOS 10.0, *) {
if let devices = AVCaptureDevice.default(AVCaptureDevice.DeviceType.builtInWideAngleCamera, for: AVMediaType.video, position: .back) {
print("Device name: \(devices.localizedName)")
}
} else {
}
if let devices = AVCaptureDevice.devices() as? [AVCaptureDevice] {
// Loop through all the capture devices on this phone
for device in devices {
print("Device name: \(device.localizedName)")
// Make sure this particular device supports video
if (device.hasMediaType(AVMediaType.video)) {
// Finally check the position and confirm the back camera
if(device.position == AVCaptureDevice.Position.back) {
captureDevice = device
if captureDevice != nil {
print("Capture device found")
beginSession()
}
}
}
}
}
}
제거 '는 단순히입니까? [AVCaptureDevice] ' – zombie
빨간색 오류가 발생합니다 : 조건부 바인딩의 초기화 프로그램에는'[AVCaptureDevice] '가 아닌 Optional 유형이 있어야합니다. 이전에 시도했지만 그래도 계속합니다. 죄송합니다. –
선택 품목이 아니므로 if 또는 점검이 필요한 이유 – zombie