首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >'animate(withDuration:delay:options:animations:)‘用法不明确

'animate(withDuration:delay:options:animations:)‘用法不明确
EN

Stack Overflow用户
提问于 2016-09-09 02:34:19
回答 2查看 2.2K关注 0票数 1

我已经升级到最新发布的Xcode8,而这个

代码语言:javascript
复制
let mediumInterval: TimeInterval = 0.6
UIView.animate(withDuration: mediumInterval) {
  print("test")
}

给了我错误Ambiguous use of 'animate(withDuration:delay:options:animations:)'我真的看不出这里有什么模棱两可的……UIView中声明的所有animate函数都是

代码语言:javascript
复制
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编译===的===解决方案

代码语言:javascript
复制
UIView.animate(withDuration: mediumInterval, animation: {
  print("test")
}, completion: nil)

将会编译,

代码语言:javascript
复制
UIView.animate(withDuration: mediumInterval, animation: {
  print("test")
})

都会像以前一样失败。我还是不明白到底是怎么回事。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-09-10 06:40:46

看起来我一直在使用的PromiseKit有一个UIView扩展,它定义了一个冲突版本的动画(https://github.com/PromiseKit/UIKit/blob/master/Sources/UIView%2BPromise.swift)

XCode无法向我展示这两个相互冲突的版本是从哪里来的,所以我花了一段时间才明白。我已经报告了这个问题。

票数 0
EN

Stack Overflow用户

发布于 2017-03-19 22:23:10

我也犯了同样的错误,因为我忘了在动画中加一个"s“。所以也许:

代码语言:javascript
复制
UIView.animate(withDuration: mediumInterval, animation: {
  print("test")
})

不会因此而编译。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39397967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档