2015-08-18 56 views
1

我找不到调用UIView方法animateWithDuration的正确语法。我发现了一些其他人遇到过类似问题的例子,而这些解决方案似乎并不适用于最新版本的Swift 2.0。我得到这个通用错误:无法使用类型为'(...)'的参数列表调用'animateWithDuration'

无法用类型为'(duration:Double,delay:Double,options:UIViewAnimationTransition,animations:() - > _,completion:nil)的参数列表调用'animateWithDuration' '

我相信我已经将问题缩小到“动画:”参数。这里是我的代码:

UIView.animateWithDuration(duration: 0.2, 
    delay: 0.0, 
    options: UIViewAnimationTransition.FlipFromLeft, 
    animations: { 
     // Hide image here 
    }, 
    completion: nil) 

任何建议,将不胜感激,谢谢。

回答

1

试试这个:

UIView.animateWithDuration(0.2, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {() -> Void in 
     }, completion: nil) 

Xcode的代码完成通常有助于弄清楚这些东西。 :-)

另外,对于动画选项,您正在使用一个常量来表示其他内容。改为使用UIViewAnimationOptions

+0

此代码编译,但我需要一个接受的animateWithDuration方法“选项:”参数,这样我可以翻转图像部分。我试图实现类似于此的瓦动画:http://stackoverflow.com/questions/12292431/image-spliced-into-tiles-with-animation-ios – Bast1472

+0

谢谢,这是问题! – Bast1472

0

得到的第一个参数摆脱持续时间标签:

UIView.animateWithDuration(0.2, 
    delay: 0.0, 
    options: UIViewAnimationTransition.FlipFromLeft, 
    animations: { 
     // Hide image here 
    }, 
    completion: nil) 
+0

谢谢,我把它留在原地,因为编译器似乎不介意。没有那个标签,我仍然看到同样的错误。 – Bast1472

相关问题