- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过点击 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
})
})
}
最佳答案
更改最后一行,它应该可以工作
@IBAction func captureDoc(_ sender: UIButton) {
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
}, completion: { _ in })
})
}
关于swift - 无法将类型 '(String) -> Void' 的值转换为预期参数类型 '((AnyObject!) -> Void)!',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38429757/
此代码将(在 Swift 1.2 中)在最后一行失败: import Foundation let dictionary1 = [String: AnyObject]() NSUserDefaults
我需要做一些简单的事情,比如将 [AnyObject?] 转换为 [AnyObject]。所以数组中的可选值应该被解包,如果为 nil 则被踢出数组。在 Swift 中有一种简单的方法可以做到这一点吗
我正在尝试使用 UIActivityViewController 共享联系人 .vcf 文件。但我收到“任何对象?”与“AnyObject”不同 下面是我的代码行: let dirs : [Strin
import Cocoa class Brain{ var internalProgram = [AnyObject]() var program:AnyObject{
如何将协议(protocol)实例数组向下转换为 AnyObject?我在下面的代码示例中尝试了一些更合理的想法。 protocol Nameable : class { var name:
在默认模板中我们可以找到以下代码: func application(application: UIApplication, didFinishLaunchingWithOptions launchO
阅读 Apple 的代码我看到了以下内容(谈论钥匙串(keychain)服务): query[kSecAttrService as String] = service as AnyObject? An
我正致力于从 Objective-C 教程转换此委托(delegate)协议(protocol)函数,但在尝试通过使用下标返回基于键的值来访问字典中的值时遇到错误。我不太确定这里的错误是什么意思。任何
我正在尝试使用 performSegueWithIdentifier 将一些字符串数据传递给 View Controller ,但我收到此错误 Cannot convert value of type
如果你看一下这个函数: typealias JSONDictionary = [String: AnyObject] private func allIdentifiersInJson(json: [
我正在尝试调用一个 Objective-C 方法,该方法采用一个 block ,该 block 使用 NSArray 进行回调。 我得到以下编译错误: AnyObject[] 不是 AnyObject
我正在为 IOS 学习 swift ,当我在 youtube 上做巡回演出时(Swift:Skip Wilson 的 Swift:使用外部数据库和 API)对于外部数据库,我找到了部分: servic
我很难理解为什么 AnyObject 的实例等于 Anyobject 的数组,即为什么这个语句 var one: AnyObject = [AnyObject ]() 有效吗? 最佳答案 用这段代码
我有两段几乎相同的代码让我感到困惑。两者都以令我惊讶的方式运作。第一个作品,如下所示: let HTTPBody = NSJSONSerialization.dataWithJSONObject(js
我正在使用 swift 库 "Sync" from Hyperoslo将 JSON 用户转换为核心数据对象。 let user = JSON.valueForKey("user") Sync.chan
我在 Swift 3.0 中工作,我的数组有问题。每行包含一个包含 2 个值的字典。 当我想更改此值时,我收到此消息: “无法使用类型为‘AnyObject’的索引下标类型为‘[AnyObject]’
let otherArray:[AnyObject] = ["a","aa","aaa"] let otherArrayElemnt = otherArray[0] let myArr
我在我的 AppDelegate.swift 文件中发现了这个错误,它出现在 AppDidFinishLaunchingWithOptions 函数中。它在来自 Parse 框架的一行代码上引发错误。
我正在尝试将我当前的项目转换为 Swift 3,但遇到了有关 objectForKey 的问题至 objectFor转换。 myData 的类型是 AnyObject 之前: let x = myDa
我有一个方法: func tableAsDictionary() -> [String: AnyObject] 然后我需要测试这个: let tableDictionary = table.table
我是一名优秀的程序员,十分优秀!