我升级到新发布的Xcode 8,这个
let mediumInterval: TimeInterval = 0.6
UIView.animate(withDuration: mediumInterval) {
print("test")
}
给了我错误Ambiguous use of 'animate(withDuration:delay:options:animations:)'
我真的看不出这里有什么含糊之处... animate
中声明的所有UIView
函数都是
open class func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions = [], animations: @escaping () -> Swift.Void, completion: (@escaping (Bool) -> Swift.Void)? = nil)
open class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Swift.Void, completion: (@escaping (Bool) -> Swift.Void)? = nil)
open class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Swift.Void)
open class func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions = [], animations: @escaping () -> Swift.Void, completion: (@escaping (Bool) -> Swift.Void)? = nil)
===解决方法让xcode编译===
UIView.animate(withDuration: mediumInterval, animation: {
print("test")
}, completion: nil)
将编译,
UIView.animate(withDuration: mediumInterval, animation: {
print("test")
})
将像以前一样失败。我仍然没有得到正在发生的事情......
答案 0 :(得分:1)
我有同样的错误,因为我忘了添加一个" s"到"动画"。 也许吧:
UIView.animate(withDuration: mediumInterval, animation: {
print("test")
})
因为这个原因而不能编译。
答案 1 :(得分:0)
看起来我一直在使用的PromiseKit有一个UIView的扩展,它定义了一个有冲突的动画版本(https://github.com/PromiseKit/UIKit/blob/master/Sources/UIView%2BPromise.swift)
XCode无法向我展示两个冲突版本的来源,所以我花了一段时间来抓住它。我已经报告了这个问题。