Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView没有成员animateWithDuration?_Ios_Animation_Swift_Ios8 - Fatal编程技术网

Ios UIView没有成员animateWithDuration?

Ios UIView没有成员animateWithDuration?,ios,animation,swift,ios8,Ios,Animation,Swift,Ios8,我正在制作一个iOS8应用程序,我正在尝试为其中一个UIView设置动画。我也在用斯威夫特。当我尝试在UI视图上使用“animateWithDuration”方法时,我在Interface Builder中创建了该方法,然后在代码中使用了IBOutlet,Xcode给了我一个错误 “UIView”没有名为“animateWithDuration”的成员 我唯一导入的框架是UIKit。现在有人知道为什么这不起作用了吗? 当我说UIView.animateWithDuration时,我没有得到任何错

我正在制作一个iOS8应用程序,我正在尝试为其中一个UIView设置动画。我也在用斯威夫特。当我尝试在UI视图上使用“animateWithDuration”方法时,我在Interface Builder中创建了该方法,然后在代码中使用了IBOutlet,Xcode给了我一个错误

“UIView”没有名为“animateWithDuration”的成员

我唯一导入的框架是UIKit。现在有人知道为什么这不起作用了吗?
当我说UIView.animateWithDuration时,我没有得到任何错误,但是当我尝试使用在Interface Builder中创建的视图时,我得到了错误。

也许你的说法是错误的。应该是:

UIView.animateWithDuration(1.0, animations: { () -> Void in
    //changes to animate
})

这就是在swift中调用类方法的方式

我假设您试图使用UIView子类的实例调用此方法。但您不应该使用类方法,所以请使用UIView(正如Heliem所说)并在其闭包中进行更改

var myView:MyViewSubclass = MyViewSubclass()

UIView.animateWithDuration(1.0, animations: { () -> Void in
//changes to animate myView
     //to animate frame changes
     myView.Frame = newFrame

})

你能提供更多的代码吗?