我很难理解我遇到的问题。 为了简化,我将使用UIView方法。 基本上,如果我写的方法Swift完成块
UIView.animateWithDuration(1, animations: {() in
}, completion:{(Bool) in
println("test")
})
它工作正常。 现在,如果我做同样的方法,但创建一个字符串,像这样:
UIView.animateWithDuration(1, animations: {() in
}, completion:{(Bool) in
String(23)
})
它停止工作。编译器错误:通话中参数'延迟'缺少参数
现在,这里是奇怪的部分。如果我做同样的代码失败的一个,但只需添加一个打印命令,像这样:
UIView.animateWithDuration(1, animations: {() in
}, completion:{(Bool) in
String(23)
println("test")
})
它开始重新工作。
我的问题基本上是一样的。我的代码:
downloadImage(filePath, url: url) {() -> Void in
self.delegate?.imageDownloader(self, posterPath: posterPath)
}
不起作用。但如果我改变。
downloadImage(filePath, url: url) {() -> Void in
self.delegate?.imageDownloader(self, posterPath: posterPath)
println("test")
}
甚至:
downloadImage(filePath, url: url) {() -> Void in
self.delegate?.imageDownloader(self, posterPath: posterPath)
self.delegate?.imageDownloader(self, posterPath: posterPath)
}
它工作正常。 我不明白为什么会发生这种情况。我接近接受这是一个编译器错误。
谢谢。但是,为什么它不会失败,如果我添加字符串(23)并再次复制相同的行,如:String(23);串(23); ? – Wak 2014-09-21 02:45:57
我实际上是在澄清,在答案中。请参阅编辑。 – 2014-09-21 02:50:13
感谢您的回答;帮助我弄清楚为什么我得到一个奇怪的“无法使用参数列表类型...”错误调用'animateWithDuration'。原来的解决方案是完全一样的。 – SonarJetLens 2014-10-06 12:39:49