【发布时间】:2015-01-22 10:11:35
【问题描述】:
我使用此代码在 iOS 自定义相机应用程序中实现 Tap-to-Focus,但它不起作用。这是代码
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touchPer = touches.anyObject() as UITouch
let screenSize = UIScreen.mainScreen().bounds.size
var focus_x = touchPer.locationInView(self.view).x / screenSize.width
var focus_y = touchPer.locationInView(self.view).y / screenSize.height
if let device = captureDevice {
if(device.lockForConfiguration(nil)) {
device.focusMode = AVCaptureFocusMode.ContinuousAutoFocus
device.focusPointOfInterest = CGPointMake(focus_x, focus_y)
device.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure
device.unlockForConfiguration()
}
}
}
【问题讨论】:
-
它不起作用怎么办?会产生什么错误?预期的行为是什么?实际行为是什么?
-
我触摸一点。并且重点应该在这一点上。但没有效果。它没有集中在那个点上。相反,它始终处于无限远焦点。那就是问题所在。 @大卫
-
你有没有通过它来确保两个 if 都被采纳?
-
是的。我在每个 if 后面放了一个 println()。他们正在经历 ifs。
-
为什么我的问题被否决了?
标签: ios swift avcapturesession