我正在尝试通过点击 captureDoc 按钮来捕获图像。但是当我突然写这个函数时,我在完成处理程序中得到了上述错误,
self.scanDoc.captureImageWithCompletionHander({(imageFilePath: String) -> Void in
而且我不明白出了什么问题。下面是我的 captureDoc 函数代码。
@IBAction func captureDoc(sender: AnyObject) {
weak var weakSelf = self
self.scanDoc.captureImageWithCompletionHander({(imageFilePath: String) -> Void in
var captureImageView: UIImageView = UIImageView(image: UIImage.imageWithContentsOfFile(imageFilePath)!)
captureImageView.backgroundColor = UIColor(white: 0.0, alpha: 0.7)
captureImageView.frame = CGRectOffset(weakSelf.view.bounds, 0, -weakSelf.view.bounds.size.height)
captureImageView.alpha = 1.0
captureImageView.contentMode = .ScaleAspectFit
captureImageView.userInteractionEnabled = true
weakSelf.view!.addSubview(captureImageView)
var dismissTap: UITapGestureRecognizer = UITapGestureRecognizer(target: weakSelf, action: #selector(self.dismissPreview))
captureImageView.addGestureRecognizer(dismissTap)
UIView.animateWithDuration(0.7, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.7, options: .AllowUserInteraction, animations: {() -> Void in
captureImageView.frame = weakSelf.view.bounds
})
})
}