无法使用类型的参数列表调用 animateWithDuration
Cannot invoke animateWithDuration with an argument list of type
我正在尝试将 JSSAlertView (github.com/stakes/JSSAlertView) 与 Swift 2.0 一起使用,但出现错误:
Cannot invoke animateWithDuration with an argument list of type '(Double, delay: Double, usingSpringWithDampling: Double, initialSpringVelocity: Double, options: nil, animations () -> _, completion: (Bool) -> _)'
代码:
UIView.animateWithDuration(0.5, delay: 0.05, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.5, options: nil, animations: {
self.containerView.center = self.rootViewController.view.center
}, completion: { (finished: Bool) in
})
我看到了这两个答案:
Nested closures does not like argument list
UIView Animation in Swift not working, wrong arguments error
但他们对我没有帮助。
我仍然认为问题来自 "animations" 或 "completion"。
您必须提供与 nil
不同的 options
。例如 .CurveEaseInOut
:
UIView.animateWithDuration(0.5, delay: 0.05, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.5, options: .CurveEaseInOut, animations: {
self.containerView.center = self.rootViewController.view.center
}, completion: { (finished: Bool) in
})
从 Swift 2 开始,选项集不再 nil
可转换,因此您不能使用 nil
。但是,它们是数组文字可转换的(对于要一起进行或运算的选项数组),因此您可以使用 []
来表示没有选项。
我正在尝试将 JSSAlertView (github.com/stakes/JSSAlertView) 与 Swift 2.0 一起使用,但出现错误:
Cannot invoke animateWithDuration with an argument list of type '(Double, delay: Double, usingSpringWithDampling: Double, initialSpringVelocity: Double, options: nil, animations () -> _, completion: (Bool) -> _)'
代码:
UIView.animateWithDuration(0.5, delay: 0.05, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.5, options: nil, animations: {
self.containerView.center = self.rootViewController.view.center
}, completion: { (finished: Bool) in
})
我看到了这两个答案: Nested closures does not like argument list UIView Animation in Swift not working, wrong arguments error 但他们对我没有帮助。
我仍然认为问题来自 "animations" 或 "completion"。
您必须提供与 nil
不同的 options
。例如 .CurveEaseInOut
:
UIView.animateWithDuration(0.5, delay: 0.05, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.5, options: .CurveEaseInOut, animations: {
self.containerView.center = self.rootViewController.view.center
}, completion: { (finished: Bool) in
})
从 Swift 2 开始,选项集不再 nil
可转换,因此您不能使用 nil
。但是,它们是数组文字可转换的(对于要一起进行或运算的选项数组),因此您可以使用 []
来表示没有选项。