这个手动对焦的代码工作到几天前。现在它不起作用......有谁知道为什么?
@IBAction func tap23(_ sender: UITapGestureRecognizer) {
if (sender.state == .ended) {
let thisFocusPoint = sender.location(in: photoImage)
print("touch to focus ", thisFocusPoint)
let focus_x = thisFocusPoint.x / view.frame.size.width
let focus_y = thisFocusPoint.y / view.frame.size.height
if (currentCamera!.isFocusModeSupported(.autoFocus) && currentCamera!.isFocusPointOfInterestSupported) {
do {
try currentCamera?.lockForConfiguration()
currentCamera?.focusMode = .autoFocus
currentCamera?.focusPointOfInterest = CGPoint(x: focus_x, y: focus_y)
if (currentCamera!.isExposureModeSupported(.autoExpose) && currentCamera!.isExposurePointOfInterestSupported) {
currentCamera?.exposureMode = .autoExpose;
currentCamera?.exposurePointOfInterest = CGPoint(x: focus_x, y: focus_y);
}
currentCamera?.unlockForConfiguration()
} catch {
print(error)
}
}
}
}
我相机的预览图层是UIImageView。几天前它是UIView ...拜托,任何人......这是我的第一个iOs应用程序